Langton's Ant is an algorithm which (like many others) generates complex behavior from simple rules. For some info about and implementations of the basic ant program, you can check out:
SRL ALife - Virtual Ants for a decent introduction to Langton's Ant. There is a Java Ant program there, but it doesn't work with the JVM that came with OS/2 Warp 4. (I haven't tried it with a Win95 JVM yet.)
Ants for Java, OS/2, MS systems, and even a TI-82 implementation of a generalized ant program.
Kasprzyk's ALife Page for a Macintosh implementation.
For my implementation, I typed in the basic algorithm (remembering it from a Scientific America article I read many years ago) and started playing with the color scheme. Unlike most multi-color ant implementations, mine doesn't change the basic ant algorithm. Instead it just overlays a color scheme on top of it, using events occuring during the basic algorithm to help select when and to what the color changes. One change I did make to the basic algorithm was that if the ant hits the edge of the screen, it will turn (and thus stay on the screen).
The program requires:
Win32 (9x, ME, NT, or XP) (it has not been tested under NT)
DirectX 5.0 or later
A Pentium compatible processor
Windows support for 640x480 @ 16 bit color
pkunzip or compatible program (such as Info-ZIP)
Before downloading the program, you should note that, like most other freeware, this software comes with no warranty of any type and you run it at your own risk.
If you want to take a look at it and you're system meets the above requirements, then download ant.zip (45,561 bytes), unzip it, and run ant.exe. To quit the program, press Esc.
Known problems/irregularities with the program:
The program creates a file called "trace" in the current directory. This is where the program lists any errors that occur.
My current DirectX library has a bug which causes it to quit the 2nd time that you Alt-Tab away from it.
The program manipulates color values directly without going through any RGB conversion, so different video cards can result in slightly different color schemes (but they should all yield the same general appearance).
Some properties of the program:
On my P133, the ant moves about 200,000 pixels per second. [This program really isn't written for speed, but it is in sharp contrast with the one Java program that actually worked for me - at about 2 pixels per second.] Currently, the program is set to limit the ant's movement to 4000 pixels per frame (so if your monitor's refresh rate is 100Hz, the speed will be limited to 400,000 pixels per second no matter how fast your computer is).
Double-buffered animation is used. [The ant moves so fast that, without double-buffering, the ant's path could flicker and look broken.]