This simulation needs WebAssembly, and it could not start in this browser.
The image is a frame from a real run. Check that JavaScript is on, or try another browser.
Langton’s ant is a two-dimensional Turing machine that Christopher Langton introduced in 1986. An ant sits on a grid of white cells. On a white cell it turns 90° to the right, on a black cell 90° to the left, then it flips the color of the cell and steps forward. For about ten thousand steps this rule draws an irregular, chaotic blob. Then the ant suddenly starts to build a “highway”: a cycle of 104 steps that moves it two cells diagonally and that it repeats forever. Whether every finite starting pattern ends in a highway is still an open question. What has been proved is that the ant’s path is always unbounded (Bunimovich and Troubetzkoy, 1992) and that the ant can simulate any Boolean circuit (Gajardo, Moreira and Goles, 2002).
Greg Turk and Jim Propp extended the ant to more than two colors. A rule such as RLLR then lists the turn for each cell state, and each visit advances the cell to the next state.
What you see
The grid has 200 by 200 cells and its edges wrap around, so it is a torus. The ant starts in the center, facing up, on an empty grid, and is drawn as the red cell. Cells in state 0 are near black and cells in state 1 near white, so the classic ant appears as the negative of the usual black-on-white picture. Further states are blue, orange, green, purple, yellow and cyan.
Each frame runs 50 ant steps, about 3000 steps per second at 60 frames per second, and the step counter above the canvas counts ant steps. The speed slider multiplies the rate up to 16 times.
Rule
With a rule word of letters, every cell holds a state , all 0 at the start. At each step the ant, on a cell in state :
- turns 90° right if or 90° left if ,
- sets the cell to ,
- moves one cell forward.
The classic ant is the rule RL. Rules whose letters come in pairs of equal letters when the word is read as a cycle (LLRR and RRLLRRLL directly, RLLR once its last R is moved to the front) grow patterns that become mirror symmetric again and again, as Gale, Propp, Sutherland and Troubetzkoy proved in 1995.
Presets
Classic RL (highway): the chaotic phase ends at step 9976, about 3.3 seconds in. By then the blob is 49 by 45 cells with 720 cells flipped. The highway leaves through the edge of the grid at step 14,255, comes back in on the opposite side, and at step 19,305 (about 6.4 seconds) runs into the old pattern, which starts the chaos again. Later highways form and break up the same way: within the first million steps there are ten that last more than 1000 steps. On an infinite plane the first highway would go on forever.
RLLR (symmetric growth): no highway. The pattern grows as a compact, roughly square blob that keeps returning to mirror symmetry. It is 24 cells wide after 10,000 steps, 74 by 84 after 100,000 and 174 by 196 after a million, and it reaches the edge of the grid after 1,005,255 steps, about 5.6 minutes at normal speed.
LLRR (slow symmetric growth): also symmetric, but it grows more slowly: 40 by 52 cells after 100,000 steps and 79 by 98 after a million.
RRLLRRLL (eight colors): the turn depends only on the state modulo 4, so the ant walks exactly as it does for RRLL, the mirror image of LLRR. The pattern is the LLRR one reflected left to right, with eight colors instead of four.
Parameters
Rule: the turn sequence, one letter per cell state. Besides the presets the list has RLR, which grows chaotically and showed no highway within 2 million steps, and RRLL and LRRL, the mirror images of LLRR and RLLR. A new rule takes effect on reset.
Resolution: the side of the grid, 50 to 400 cells (default 200). Changing it starts the ant again on a new grid. The times above are for 200 cells.