Langton’s Ant

[insert_php]require(‘./code/megastorm.php’ ); $pIndex = “Langton-SDL”; [/insert_php]


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 Linux (x86), MacOS X (10.4 to 10.14) and Windows (95 to 10 x86).
  • Makefile for Linux and MacOS X are not available.
  • 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!


[insert_php] printDetails(); [/insert_php] | Free and open-source

32bits binaries for supported operating systems.
    [insert_php] printDownload(“win-x86″,”zip”,”icon-os-windows-vs.png”, “Windows”); [/insert_php]
Source code
Source code and make files for VS2003+.
    [insert_php] printDownload(“source”,”zip”,”icon-source-code1.png”, “Source code”); [/insert_php]
Previous releases
Get access to all releases repository.
    [insert_php] printRepository(); [/insert_php]