Hive is a programming game inspired by Nodewar, the Google AI Challenges, and Code Combat. It's intended work as both a stimulating AI competition and a fun environment for new coders. Hive is best when played against friends!

Hive also draws inspiration from social insects. "Superorganisms" are remarkable examples of distributed intelligence and pose unique AI challenges. Emergent colony behavior from simple individual rules is one of the most rewarding aspects of this project.


One of the primary goals of this project was to create an easy to use and friendly programming environment for people of all skill levels to play. This meant avoiding as much accidental complexity as possible. The model of having a program run for each ant individually meant that each ant must yield control of the thread to the main program constantly, necessitating an asynchronous coding architecture.

Unfortunately, as many people learning asynchronous javascript for the first time can attest, this can be very frustrating. We didn't want to force the users of our game to learn to use promises, callbacks, or other more complex asynchronous coding constructs in order to program a simple bot.

Instead, we use a code transformation which compiles the user's code into a large state machine which can be suspended and resumed at critical points in the program's execution. This allows for the program to be written with a traditional imperative control flow, making functions like move('left') suspend the subroutine, and allow the rest of the program to execute.

Originally, we used a library called Aether, created by the people at CodeCombat to sandbox and allow easier debugging of the code their users enter. Unfortunately, this library has a severe limitation that functions cannot be defined locally, due to the model which it uses for the translation into a state machine. Because of this, we wrote our own library using regenerator to create a state machine which allows us to transparently use functions, while still having the easy to use imperative code flow.


Developing the API which is exposed to the players was the most challenging aspect of this project. Balancing power with complexity as well as allowing the user to program in a pseudo-synchronous paradigm, which is easier to write and understand than traditional asynchronous callback heavy JS. Michael did some heavy hacking in this department, writing a library to transform input javascript into a gigantic state machine.

Some other challenges included wrestling with unexpected library limitations and keeping architecture sane across a large codebase with four active contributors learning new skills.

What's next for Hive

We hope to foster an active online community through socially oriented features such as a ladder/leaderboard, discussion forum, open source AI collaboration, and friendly tournaments. We can't wait to see how people move their Ants!

Built With

Share this project: