An interactive explainer

No ant knows the map. The road appears anyway — and heals itself when you break it.

Ant colonies find their way with no leader and no map: each ant leaves a little scent where it walks, and follows the stronger scent it meets.

Repeated by hundreds of ants, and slowly forgotten by the ground, that one rule is enough for a road to appear — and it is the idea behind a family of computer algorithms called ant colony optimisation, used for routing and scheduling.

Below is a colony of four hundred simulated ants that follow only that rule. Press Run, then draw a wall across their road and watch what happens.

See it run ↓
The simulation twenty seconds in: a road of amber scent marks threading between grey blocks from the nest to the food, black and red ants along it.
Twenty seconds in, with random obstacles.

Press Run

For the first few seconds they spill everywhere; then one route thickens, the rest fade, and within twenty seconds there is a road. Nobody chose it — the first ants to make it home reinforced their own path, so it is usually short and sometimes not, and the number beside the field tells you which.

Draw a wall

Draw a wall across the road: the ants pile against it, spill round the ends, and within seconds a new road has formed. No ant noticed a problem — the blocked road simply stopped being reinforced, and wherever enough ants got through, their scent became the road.

Try both ends

Set forgetting to zero, press Reset and let a road grow before you break it: scent that never fades keeps them pouring into the dead end long after it is one. Push forgetting to the far right and no road survives at all; between those two ends the road forms and repairs itself every time — a tendency, not a guarantee, and no ant is doing the planning.

no reading yet

warming up

walls: 0

Scene
Walls