Halite is a new AI programming competition that was recently released by Two Sigma and Cornell Tech. It was designed and implemented by two interns at Two Sigma and was run as the annual internal summer programming competition.
While the rules are relatively simple, it proved to be a surprisingly deep challenge. It’s played on a 2D grid and a typical game looks like this:
Each turn, all players simultaneously issue movement commands to each of their pieces:
- Move to an adjacent location and capture it if you are stronger than what’s currently there.
- Stay put and build strength based on the production value of your current location.
When two players’ pieces are adjacent to each other, they automatically fight. A much more detailed description is available on the Halite Game Rules page.
Bots are run as subprocesses that communicate with the game environment through
STDOUT, so it’s very simple to create bots in the language of your choice. While Python, Java, and C++ bot kits were all provided by the game developers, the community quickly produced kits for C#, Rust, Scala, Ruby, Go, PHP, Node.js, OCaml, C, and Clojure. All the starter packages are available on the Halite Downloads page.
Clojure Bot Basics
The flow of all bots are the same:
- Read the initial state (your player ID and the starting game map conditions)
- Write your bot’s name
- Read the current gam emap
- Write your moves
- GOTO #3
The Clojure kit represents the game map as a 2D vector of
1 2 3 4 5 6
And movement instructions are simple keywords:
A simple bot that finds all the sites you control and issues random moves would look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
There are currently almost 900 bots competing on the site, but there are only a handful written in Clojure! I’m sure the Clojure community could do some interesting things here, so head over to halite.io, sign-up using your Github account, and download the Clojure starter kit.