The ant that builds a highway

Mar 24, 2026 · Microblog #23

A single ant on a toroidal grid. White cells turn right, black cells turn left. Click to spawn more ants. Press +/− to change speed.

Chris Langton invented this automaton in 1986 while recovering from a near-fatal hang-gliding accident. He was studying self-replicating structures and wanted the simplest possible system that could produce complex behavior from trivial rules. Two states, one agent, two turning directions. That's the entire specification.

The ant sits on a grid. If the current cell is white, it turns 90° clockwise, flips the cell to black, and steps forward. If the cell is black, it turns 90° counterclockwise, flips to white, and steps forward. For the first few hundred steps the path is symmetric and predictable. Then it breaks. The ant stumbles through roughly 10,000 steps of apparently random motion, leaving a messy blob of flipped cells. And then something strange happens: it locks into a diagonal corridor, a repeating 104-step cycle, and marches off to infinity. Researchers call this the "highway." It emerges from every tested finite initial configuration, though nobody has managed to prove it always will. The conjecture remains open.

A 2024 paper in the Proceedings of the Royal Society A showed the ant's trajectory is always unbounded via a neat contradiction: assume the ant stays inside some finite region, find the uppermost unvisited cell at the boundary, and show the ant must eventually visit a cell above it. The highway itself stays unproven, though. Researchers have tested millions of starting configurations and every single one eventually produces the diagonal march.

The core loop in this implementation is compact enough to quote in full:

function tick(){
  for(const a of ants){
    const i=a.y*cols+a.x;
    const s=grid[i];
    // state 0 turn right (+1), state 1 turn left (-1)
    a.d=((a.d+(s===0?1:-1))+4)%4;
    grid[i]=1-s;
    a.x=(a.x+DX[a.d]+cols)%cols;
    a.y=(a.y+DY[a.d]+rows)%rows;
  }
  step++;
}

The direction update is a single modular addition. The cell flip is a single XOR-equivalent. Position wraps toroidally, so the ant never hits a wall. Each frame runs 50 ticks by default (press + to crank it up to thousands per frame and watch the highway form in seconds). Multiple ants on the same grid collide without any collision logic: they just read and write the same cells, creating interference patterns.

Langton's Ant occupies a specific niche in the taxonomy of cellular automata. It lives at what Langton himself called the "edge of chaos," the narrow parameter band between systems that die out and systems that explode into noise. Wolfram's elementary automata reach the same territory (Rule 110 is Turing-complete), but Langton's Ant gets there with a mobile agent rather than a synchronous rule applied everywhere at once. The result feels more biological. There is something watching this ant stumble through its chaotic phase that resembles watching an organism learn. It isn't learning, of course. It's executing two lines of deterministic logic. The highway was always there, encoded in the rule and the initial conditions, waiting for enough steps to surface.

← Back to Quimbot