Snowball Fighting in the ACM Programming Challenge

The Association of Computing Machinery is currently holding a neat programming contest.  Competitors write a program to control a team of virtual children engaged in a snowball fight withan opposing team.

The game rules are really well designed: simple enough to quickly grasp, but with enough features to make the gameplay interesting.  The game takes place in a field composed of 31x31 squares.  Each square can hold either a tree (which blocks both movement and flying snowballs), a child, or some arrangement of snow.  There is limited visibility, commonly known as "fog of war," and snowmen (towers).  Snowmen both provide "control" of an area of the field, which gives points in the game, and also provide visibility around them.  Enemy snowmen can be captured, simply by removing the last snowball (the head) and putting it back on.  Finally, points are also awarded for hitting opponent kids with a snowball... but game mechanics enable kids to duck, dodge, and hide behind piles of snow.
Contest Picture
So these mechanics enable a wide range of strategies: you can build snow forts and hunker down, or stay on the move, or concentrate on controlling territory with snowmen, or any combination of those.

The game engine is written in Java, and runs nicely on my Mac; I hear it works pretty well on Windows and Linux as well.  Contestants can write their entries in C++, C# (via Mono), Java, or Python.

Luminary Apps is entering this contest as an informal off-hours exercise.  We began by writing a pair of programs in REALbasic that allow us to play the game manually, like a turn-based strategy game.  The first program is a command-line client that basically pipes stdin and stdout, which are used to communicate with the contest game engine, to a socket.  Then the second program is a GUI client that connects to the virst via TCP/IP.  So we can easily set up a two-person networked game, or a one-person game against any of the AIs.

Playing this a while gave us some ideas about strategy and tactics, so then we started writing our own AI to enter in the contest.  Our entry is written in C++, and was based originally on the C++ sample code included with the contest package.  So far we don't have any strategy or coordination built in; our little guys just throw very accurately, capture any snowman they see, and build their own snowmen when they have nothing better to do.  But so far, they've won 5 out of 6 games against randomly selected opponents -- and the sixth was lost by only about 30 points (out of 400).

So I think we're doing pretty well so far, and if we can add some more sophistication and coordination to their movements, we might have a real shot.  But whether we win or lose, we're enjoying the competition!