Army ants form colonies of millions yet have no permanent home. They march through the jungle each night in search of new foraging ground. Along the way they perform logistical feats that would make a four-star general proud, including building bridges with their own bodies.

Much like the swarms of cheap, dumb robots that I explored in my recent article, army ants manage this coordination with no leader and with minimal cognitive resources. An individual army ant is practically blind and has a minuscule brain that couldn’t begin to fathom their elaborate collective movement. “There is no leader, no architect ant saying ‘we need to build here,’” said Simon Garnier, director of the Swarm Lab at the New Jersey Institute of Technology and co-author of a new study that predicts when an army ant colony will decide to build a bridge.

Garnier’s study helps to explain not only how unorganized ants build bridges, but also how they pull off the even more complex task of determining which bridges are worth building at all.

To see how this unfolds, take the perspective of an ant on the march. When it comes to a gap in its path, it slows down. The rest of the colony, still barreling along at 12 centimeters per second, comes trampling over its back. At this point, two simple rules kick in.

The first tells the ant that when it feels other ants walking on its back, it should freeze. “As long as someone walks over you, you stay put,” Garnier said.

This same process repeats in the other ants: They step over the first ant, but — uh-oh — the gap is still there, so the next ant in line slows, gets trampled and freezes in place. In this way, the ants build a bridge long enough to span whatever gap is in front of them. The trailing ants in the colony then walk over it.

There’s more to it than that, though. Bridges involve trade-offs. Imagine a colony of ants comes to a V-shaped gap in its path. The colony doesn’t want to go all the way around the gap — that would take too long — but it also doesn’t build a bridge across the widest part of the gap that would minimize how far the colony has to travel. The fact that army ants don’t always build the distance-minimizing bridge suggests there’s some other factor in their unconscious calculation.