For the last four weeks, I've been working with a team of three other software engineers to build a daily artificial intelligence "battle" game. JavaScript Battle was the result.
I've always thought artificial intelligence (AI) is very cool, but one thing I'd noticed is that AI challenges can be a bit inaccessible for novice programmers (especially since most people assume that writing artificial intelligence code requires god-like programming abilities).
Our goal was to create a game that was engaging for advanced programmers/AI practicioners, but also very accessible and fun for novices/people less comfortable with AI.
Inspiration
JavaScript battle was specifically inspired by the AI challenge Vindinium.
Myself and three other UM CS/Statistics graduate students built a reinforcement-learning based "brain" to participate in Vindinium in early 2014. It was GREAT fun, but I noticed (as mentioned above) that the initial set up and "brain-building" made the game somewhat inaccessible to other, less "technical" Statistics students in my program.
As a result, myself and three other software engineers decided to build JS Battle as a fun project at the end of this Summer. Specifically, we wanted to appeal to a wider audience (easy signup, more starter code, more "fun" stats) and to allow for larger, team-based battles that require less work on the part of the users to get involved. Though JS Battle is now a much different app (different stack, setup, stats, game rules, signup, etc), the idea was inspired by Vindinium, and they should definitely get credit for that.
To conclude, Vindinium is AWESOME, and definitely worth checking out. However, we built JS Battle with slightly different goals in mind.
JavaScript Battle: The Concept
- You submit custom code to our site.
- We run your code against the code submitted by all other users in a daily battle (actually battles, since each battle caps out at 24 participants)
- You get to watch your battle the next day, see how your hero did, and make updates to your code whenever you want.
- We also provide starter code, helper functions, and in-depth instructions to help you get started.
The Game
In a nutshell, your submitted code controls your "hero" as he/she attempts to capture diamond mines, drink from health wells, kill enemy heroes, or heal friendly heroes.
The game ends when either:
- One team completely eliminates the other team, or
- After 1250 turns.
If at least one member of each team survives for the entire 1250 turns, the winning team is the one that has gathered the most diamonds.
The Site
The site consists of a few main parts:
- Signing up is as easy as logging in with your GitHub account. All you need to do then is fork our provided hero-starter repository, which will give you some choices for a "brain" to use for your hero. For more advanced users, you can also write your own "brain" from scratch (and have it do whatever you want).
- You can view the battle as a video, turn-by-turn, or scroll just to the parts you're interested in watching.
- Check out how you measure up against the competition on the leaderboard.
- Or check out your personal stats on the User Info page (available after signing in)
The Stack
- Node/Express server for the back-end of the website.
- MongoDB for the database.
- Backbone with EJS templates for front-end rendering/organization.
- Node scripts to run the game, update the leaderboard, update hero stats, and basically do everything else that happens behind the scenes (these were all automated with cron).
- Docker for running user-submitted hero code in a safe, isolated environment.
- Mocha/Chai/Supertest for testing.
- CircleCI for continuous integration.
- Microsoft Azure for our virtual machine and website deployment needs.
This was a LOT of fun for us to build. Try it out and let me know what you think!