Langton's Ant
Langton's Ant is a two-dimensional Turing machine invented by Chris Langton in 1986. On a white square it turns right, flips the square to black, and steps forward. On a black square it turns left, flips the square to white, and steps forward. From an empty grid those two rules pass through symmetry, a long chaotic tangle, and then a diagonal highway that repeats every 104 steps. Play the ant, change its turn rule, or drop more ants on the grid.
How it works
- Open this page and press play. The ant starts on an empty grid and builds the first symmetric patterns.
- Speed up to cross the chaotic phase, or open the Highway favourite to jump past 10,000 steps.
- Change the rule (RLR, LLRR, LRRRRRLLR), add ants, switch to hexagons or a turmite, then save a PNG.
Two turns, one step
Every cell is white or black, and the ant has a direction. On white it turns 90° clockwise, paints the cell black, and moves one square forward. On black it turns 90° anticlockwise, paints the cell white, and moves one square forward. Nothing else is random. The same start always makes the same picture.
Symmetry, chaos, then a highway
On an empty grid the first few hundred steps are small and often symmetric. From roughly step 500 to step 10,000 the ant is tangled in its own trail and the picture looks like noise. After about 10,000 steps it falls into a cycle of 104 moves. Each cycle lays two more cells along a diagonal, so the ant builds a highway and walks away in a straight line forever.
Colours, colonies, hexes and turmites
A rule such as RLR or LLRR gives every colour its own turn, and the ant cycles the colour instead of flipping black and white. Several ants share one grid and can erase each other's highways. On a hexagon the same idea uses six directions. A turmite adds a private state, so the turn depends on both the cell and what the ant remembers.
Frequently asked questions
What is Langton's Ant?
A cellular automaton Chris Langton published in 1986. One ant walks an infinite grid of squares. The colour under the ant decides a 90° turn, the ant flips that colour, and then it steps forward.
What are the three phases?
From an empty grid: simple, often symmetric patterns for about the first 500 steps; a chaotic tangle until about step 10,000; then a highway, a cycle of 104 steps that builds a diagonal road forever.
What does a rule like RLR mean?
Each letter is the turn for one colour. R is right, L is left. The ant writes the next colour and steps forward. RL is the classic black-and-white ant. Longer rules such as LLRR and LRRRRRLLR grow different patterns, including symmetric geometry.
What is a turmite?
An ant with a memory. The turn and the colour it writes depend on both the cell and the ant's own state, so the rule can change as it walks. The Spiral, Weave and Drift favourites are two-state turmites.
Does the simulation leave my device?
No. The grid, the ants and the picture are computed in your browser. Save a PNG or open the canvas in the PictorX editor.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Go to Editor