Langton's Ant
One ant, two rules, and a result nobody can fully explain
One ant, two rules: turn right on white, left on black, flip the square, step forward. After about 10,000 steps of apparent chaos it starts building a straight diagonal highway.
How it works
In plain English, before the notation
An ant walks on a grid of white and black squares. On white it turns right, flips the square to black, and steps forward. On black it turns left, flips the square to white, and steps forward. That is all. For the first few hundred steps the trail is neat and symmetric. Then it becomes an apparently random scribble that lasts about ten thousand steps. Then, without anything changing, the ant locks into a 104-step cycle and builds a straight diagonal road that continues forever.
Wait for the highway
- Open Presets and load "Single Ant (the classic)" — one ant, empty grid.
- Set Speed to 60 fps in Settings and press Play. Watch the Steps counter in the dock rather than the generation count.
- Around step 10,000 the scribble stops growing outwards in all directions and a straight diagonal road begins. Nothing was added to make this happen.
Starting configurations
Loads straight into the simulatorTry any rule
The catalogue covers a few dozen rules. Here you can run any of the 262,144 two-state grid rules, or any of the 256 one-dimensional rules, including ones nobody has written up.
Well-known rules
Where it came from
Christopher Langton described the ant in 1986 as part of his work on artificial life. It is the simplest well-known example of a turmite: a machine with an internal direction that moves over a grid, reading and writing one cell at a time. That makes it a Turing machine on a two-dimensional tape rather than a cellular automaton.
The three-phase behaviour was found by simulation, not predicted from the rules, and it is still not derived from them. Bunimovich and Troubetzkoy proved that the ant’s path must be unbounded — it cannot stay in a finite region forever — but that is a much weaker statement than "it always builds a highway".
The rule, precisely
What each cell looks at
None. The ant reads only the cell it occupies.
What a cell can be
Two colours per cell, plus the ant’s position and its heading (up, right, down or left)
The update
heading' = heading + (colour = white ? +90° : −90°); colour' = 1 − colour; position' = position + one step in heading'
Written as the turn string RL: turn Right on colour 0, Left on colour 1. Longer strings such as LLRR describe ants with more colours, one turn per colour.
Three phases, in order, every time
Starting from an empty grid, the same sequence occurs on every run:
- Roughly steps 0–500: small, visibly symmetric shapes.
- Roughly steps 500–10,000: an irregular patch with no discernible structure, spreading in all directions.
- From about step 10,000: a 104-step cycle that moves the ant two squares diagonally per cycle, producing an unbounded straight road.
- The transition is not triggered by anything. The ant is running the same two rules throughout.
The ant can compute
Gajardo, Moreira and Goles showed in 2002 that a suitable arrangement of black and white squares makes the ant simulate an arbitrary boolean circuit, which is enough for universal computation.
Agents that modify their environment
The ant is a minimal model of stigmergy — the mechanism by which ants and termites coordinate by changing their environment rather than by communicating directly. Its other use is as a demonstration that "unpredictable" does not require randomness: this system is fully deterministic, and the outcome is still not derivable without running it.
Things to try
- The Steps readout in the dock counts individual ant moves, which is the number quoted in the literature. The simulator runs several moves per displayed frame so the motion is visible.
- Once the highway has started, pause and draw a short black wall across it with the Pencil. The ant is usually thrown back into a chaotic phase, and will eventually build a new highway in some other direction.
- Use the Place Ant tool to add a second ant. Two ants interfere with each other’s trails and neither follows the usual schedule.
Frequently Asked Questions
References
Covers the three phases, the Cohen–Kung result, and the generalisation to multi-colour ants.
The 104-step highway cycle and the geometry of the road it builds.
The proof that the ant can simulate boolean circuits and that predicting it is P-complete.
