Virtual Ant Farm

What is it?

Sorry, but you need Java to see the ant farm.

The applet is a virtual ant farm. The ants are the red pixels (If you have a high resolution monitor, I recommend either dropping the resolution or using a magnifing application (one comes with Windows 98 and can be installed from accessability options)). The white trails are areas without sand, and the orange/brown is sand. Green pixels represent food, and dead ants are blue pixels.

At the bottom of the tank is a trace line that shows how long the oldest ant lived in each generation. This gives a rough estimate of how well the ants are evolving.

The movement of the ants is decided from the ants present state using a hash table of [state,action] tuples. An ants state is governed by a number, where each bit represents an aspect of its surrounding. For example, one bit is set according to if the ant can move forward, another is set if the ant is hungry. Further bits represent other things, and to make motion more random (and to avoid repetative loops in behaviour) one bit is randomised.

Having generated a state, the action for the ant is decided by looking up a value in the hash table. Not all states have an action entry, and the default action is to walk forward. Possible actions for the dot are to turn left or right.

Ants are damaged by either starvation, or over eating. Eventually all the ants in a given tank die from one of these factors.

After all ants are dead, they are ranked by the longest surviving ant. The tables that control behaviour are then modified, mutated, cloned or randomized, depending on the ranking of each ant, and the process starts again.

If you open up the java console window, you will see occasional statistics about each dot.

I have left this running for a few days, and found that the ants started to live up to 186794 turns! My friend got ants that lived to twice this age. So it does work, but it takes a long time...

Current Features

The tank runs as a separate thread to allow screen redraws to happen in another thread. Can place it on the active desktop to keep it running. If the applet is allowed to, it will save all information regarding the ant farm to a file which it will allways attempt to read at startup.

Future directions

I would like to run an ant server, where peoples ants could be stored. I would envisage a system using UDP messages to send the behaviour tables to the server. The server could then store them, rank the ants (either by data sent along with the ant, or by testing them in a server side tank). This may not be possible however, as being an Undergraduate, I doubt they would let me run a server app on one of the servers (I don't even get CGI without user authentication).

People running the ant applet could then choose to download an ant via a net connetion.

Also plan to make it as a free standing applet so that it can write to disk to save state.

Would like to add some other things such as gravity to make the sand compact and flow. Also need a sand and food regeneration scheme.

Add a trend line to the trace.

Add simple user interface to allow user to customise. Learn Swing?

Make it use less CPU, have an option to run it as a screensaver.

This page is maintained by Michael McTernan