The Giver — my submission to ICFP 2004.

This year's task on ICFP contest 2004 (June 4-7.) was to gather the most food possible with 91 ants. You compete with other competitors' ants, you control the red ants against the black ants or in the other way round. Food must be carried from food piles to the anthill, and can be stolen from the other anthill.

What makes the task difficult is that the ants have a very simple brain: a state automaton with at most 10_000 states, and no other kind of memory. The ant knows very few commands, and it can only see its immediate environment. The ant can place chemical signals on the terrain which other ants can smell. Moving the ant is much slower than any of the other operations.

(This is not by any chance meant as a complete description of the task, see the official task description instead.

I, Zsbán Ambrus competed alone (this is a team contest), with the code name The Giver.

I spent a lot of time writing a simulator for the task. Despite of the detailed information (including a lot of pseudocode) given in the task description, the debugger was difficult to write. It still has some bugs: when I run the example testing world, I get a difference at round 790 with ant id 26, which executes a Flip instruction. The simulator runs really slow too, and I'm not sure how others could write it so fast.

Then, I've quickly wrote an assembler that produced the state machine as output. After that, I had too few time, so I quickly did some code, using a lot of copy-paste. The code has not been tested well. It seems that the last-minute modifications I did to it (so that the ants won't circle at the edge of the map with food) made the ants even more stupid than they were. They sometimes just freeze with the food in their mouth, and won't move.

For the development, I've used a 400 MhZ Intel Pentium-II box with Linux. I've written both the simulator and the assembler in ruby.

Here is the tarball I've submitted (1.2 kB gzipped).

Here are most of the files within:

doc/doc
tools/play
tools/first.quantas
tools/quantas
tools/my0.world
tools/solution-1.quantas
tools/gather.quantas
solution-1.ant