Clever Quest Lab ← Labs

Langton's Ant

One ant, two rules. Watch chaos turn into a road.

Readouts

Steps (generations)
0
Colored cells
0
Ants
1
Rule
RL
Zoom
1×
Highway
not yet

Paint color

The letter is the turn the ant makes on that color. Pick the first (blank) color to erase.

Presets

Rule and ants

2 to 12 letters. L = turn left, R = turn right, N = no turn, U = U-turn. Applying a rule clears the grid.

View, fill and export

Random fill resets the ants and scatters colors over the grid. The PNG always uses the light colors.

Runs on your device. Nothing you type or record is uploaded. Keeps working without a connection while the page is open. Works with touch. Saves your rule, grid size, speed, ant count and tool on this device; the grid starts fresh on every visit.

Added · Updated : removed two details without a source, the names attached to multi-colour ants and the exact step count before the highway

How to use it

Press Play and watch a single ant on an empty grid. At every step it looks at the colour of the cell it stands on, turns, flips the colour of that cell and moves one cell forward. For a few thousand steps the picture grows into a messy blob that looks random. Then, after roughly 10,000 steps, the ant suddenly builds a straight diagonal road and walks away along it. That road is the highway, and the Highway readout tells you when the page has recognized it.

The grid wraps around: leaving at the right edge brings the ant back on the left, and the same at the top and bottom. A highway therefore comes around again and eventually runs into the old mess, so larger grids last longer.

Controls

How it works

Chris Langton introduced the ant in 1986. In the original version the cells are white or black. On a white cell the ant turns 90 degrees right, turns the cell black and steps forward. On a black cell it turns 90 degrees left, turns the cell white and steps forward. Written as a rule string this is RL: the first letter says what to do on the first colour, the second on the second colour.

Extra colours work the same way. The rule is a string of letters, one per colour. Standing on colour k, the ant turns as letter k says, changes the cell to colour k+1 (the last colour wraps back to the first) and moves one step. L and R are the classic turns; this page also accepts N (no turn) and U (U-turn). Ants with more colours have been studied in depth and are often called turmites.

The highway is the surprising part. After about 10,000 steps the classic ant falls into a cycle of 104 steps that moves it two cells diagonally and leaves the same band of coloured cells behind, over and over. The page spots it by comparing the ant’s position every 104 steps and reports a highway after five identical shifts, so its estimate of the start is only roughly right.

Nothing in the two rules mentions a highway, so it is a good example of emergence. Two results are proven: the ant’s path never stays inside a finite region (Bunimovich and Troubetzkoy, 1992), and predicting its far future is computationally hard (Gajardo, Moreira and Goles, 2002). Whether every finite starting pattern eventually leads to a highway is still an open question. Every pattern tried so far has, but nobody has a proof.

Rule strings with a mirror-like structure, such as LLRR and RLLR, are known for patterns that become mirror-symmetric across a diagonal again and again as they grow (the page does not draw the symmetry line, so look for it at low speed). Other rules grow irregular blobs or large filled regions with straight diagonal edges.

Things to try

Frequently asked questions

Is the ant random?

No. Every step is fixed by the rules and the grid. It only looks random during the chaotic phase because the pattern is too tangled to predict by eye.

Why does the highway appear after about 10,000 steps?

Nobody has a simple explanation. The number comes from simulation; no short argument predicts it.

Why does a small grid behave differently?

The grid is a finite wrap-around surface, not an infinite plane. Once the highway meets its own history, the result no longer matches the infinite case.

What does the PNG contain?

The whole grid, enlarged to about 1,024 pixels on a side, with ants as dots, always in light colours.

Sources