Langton’s Ant


Langton’s Ant is a simple and deterministic discrete dynamical system. It can be viewed as a cellular automaton, as a two-dimensional Turing machine, or as an agent-system. When I say that it’s discrete, I mean that there is a discrete world, which is updated in discrete time. The world is usually a bi-dimensional square grid but is possible to code it in other ways such as triangular grid, hexagonal grid,etc. Each position in the grid (called cells) has a state, which can be either red or non-red. The ant walks on the grid, moving according to the states it finds, and changing these states as it walks over them.

It was originally coded in 1998 under MSDOS and was ported to Win32/Linux using SDL in 2002.

Langton Langton


  • Custom number of ants, position and speed using a external .ini file (with Spanish comments).
  • The ants follow these very simple rules:
    • make the first movement based on an initial direction
    • if the cell where it moves is non-RED, it changes it to RED and perform a turn of 90º at right
    • if the cell cell where it moves is RED, it changes it to non-RED and perform a turn of 90º at left
  • Once it finished, create a screenshot on an external BMP file and output some execution stats.
  • Available for Windows. It also compiles for Linux and MacOS X but make files are not provided.
  • Developed in C++ using SDL 1.2.

As you can see, the rules are very simple ones, so… where is the interesting thing? you only must run the program and after about 10,000 steps, the ant will create almost-symmetrical landscapes and it will begin to create a diagonal highway. It seems that each ant suddenly know what want to do. Many of you will say that it could be random event but far from it, we can do whatever we want with these ants: put a lot of them, put obstacles, etc.. but all of them always ended up doing his diagonal highway, you should test it!


Last version: v1.00 (15-June-2002)
ChangeLog | Roadmap | Free and open-source

32bits binaries for supported operating systems.
Source code
Source code and make files for VS2003+.
Previous releases
Get access to all releases repository.