By Tim King · Updated
Langton's Ant
Watch the Highway Emerge in Your Browser
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the Langton's Ant works
This Langton's ant simulation runs two rules into a highway. Press Play and an ant walks a grid by two rules, scribbling an apparently random blot for about ten thousand steps and then, without warning, building a diagonal highway that goes on forever. Speed it up to reach the highway in seconds, slow it down to watch each turn, or add more ants and see their patterns collide.
Langton's ant: how it works
Langton's ant, from Chris Langton in 1986, is the smallest system most people meet that behaves in a way nobody has managed to explain. The ant stands on a grid of white cells. At each step it turns right if the cell is white and left if the cell is black, flips the colour of the cell it is standing on, and moves forward one square. That is the whole rule, and it is deterministic — the same start always gives the same path.
The three phases. For the first few hundred steps the ant draws small symmetric shapes. Then it dissolves into a chaotic blob that grows slowly and looks random, though it is not. Somewhere around step 10,000 it escapes the blob and starts a "highway": a diagonal band of 104 steps that repeats exactly and heads off in one direction forever, unless it runs into something. Nobody has proved the highway always appears from every starting configuration, though it has done so in every one ever tried.
The sliders. Cell size sets the resolution of the grid; small cells give the ant more room before the highway wraps round and hits its own trail. Steps per frame is the speed — at 1 you can follow individual turns, at 500 you reach the highway in under a minute. Ants adds more ants, each starting at a random spot facing a different way, on the same grid. Their trails interact, and an ant walking into another's chaos can be captured by it or set off on a new highway.
Wrapping. The grid wraps at the edges, so the highway eventually comes back round and collides with the original blob. When that happens the ant usually falls back into chaos for a while and then builds a new highway in a new direction. Going fullscreen gives the highway further to run before this happens.
Why it is interesting. It is a two-state, two-rule Turing machine on a plane, and it is known to be capable of universal computation — any calculation can in principle be encoded in the initial colouring of the cells. The emergence of order from chaos at step 10,000 is the part people come to see, and the fact that it is not understood is the part they stay for.
FAQ
When does the highway appear?
On an empty grid, after about 10,000 steps. The step counter in the rail shows the count so you can watch for it. At 50 steps per frame that is roughly three or four seconds; at 500 steps per frame the blot and the highway appear almost at once.
Why does the ant sometimes go back to chaos?
Because the highway is only stable on empty cells. The grid wraps, so the highway eventually comes back to its own starting blob, and when the ant walks over already-flipped cells the rule sends it back into the chaotic phase. With multiple ants they disrupt each other's highways as well.
Can I change the rule?
Not here. This tool runs the original two-colour RL rule. Multi-colour extensions such as LLRR or RRLLLRLLLRRR produce different growth patterns and are worth exploring, but they are a different tool with a rule-string input rather than sliders.
Does it always look the same?
With one ant, yes: the rule is deterministic and the ant starts in the centre facing up. With more than one ant the starting positions are random, so each Restart gives a different picture.
See also: all Simulations & Screensavers tools, Images, Audio, Video & Screen, PDF, SVG, Generative Art, Chart Makers, 3D Model Viewers, Drawing Pads, Mockups & 3D Making, Diagram Makers, 3D Science, Tracker Music.
Related tools
Game Of Life
Conway's cellular automaton with cell size, density and speed sliders.
Boids Simulation
Flocking birds from three rules, with sliders and fullscreen.
Falling Sand
Paint sand, water and walls and watch them settle; fullscreen.
Reaction-Diffusion
Gray-Scott chemistry growing coral, spots and fingerprints; fullscreen.
3D Coin Flip
Toss a physics coin in 3D and watch it land heads or tails.