Getty Images / H&C STUDIO / WIRED

For the past three decades Deborah Gordon has devoted herself to studying ant colonies in the Arizona desert. Although her chosen subject – the red harvester ant – isn’t much to look at, when they come together the ants are capable of remarkable feats of organisation.

“No ant knows what it is doing or can make any kind of global assessment, but in the aggregate colonies accomplish a lot,” says Gordon, a biology professor at Stanford University in California. Harvester ants maintain complex nests built several metres underground, with an entire colony of 10,000 ants lasting between 20 and 30 years – matching the lifespan of a queen ant, whose death heralds the colony’s slow decline.


And the reason for these ant’s extraordinary success? Algorithms. Gordon’s research focuses on how different ant species have evolved algorithmic ways of responding to their environment, allowing them to balance water intake, build more efficient routes and find new food sources. And as it turns out, there are a few things that us humans can learn from ant algorithms, too.

For the harvester ants, their most important algorithm regulates their foraging. Their main source of food and water is grass seeds, which the ants store in their vast underground colonies for several months. But in the hot Arizona desert, knowing whether to expend energy and water on the hunt for grass seeds or instead hunker down and conserve resources is critical to the success of the colony.

Read next Machine learning is totally changing what we think of as literature Machine learning is totally changing what we think of as literature

The thing is, no individual ant is able of making this decision alone. Instead, forager ants rely on signals from other ants returning to the nest with grass seeds to decide whether they too should join the hunt for food. Harvester ants are coated with a stinky layer of grease which changes in odour depending on the job that ant does within a colony – so when a would-be forager smells other foragers returning at a high enough rate, it too joins the hunt for food. Ants doing other jobs can also be compelled to switch their task depending on the rate at which they encounter other kinds of ants.

This, Gordon explains, is a kind of positive feedback loop. If forgars are returning quickly, then it suggests that there is plenty of easy food out there to be collected, so it makes sense to get as many ants out there as possible collecting grass seeds and storing them for later. The harvester ants have certain ‘trigger levels’ that change depending on the humidity of the environment, but generally-speaking if a waiting ant smells 10 or more returning foragers in a 30 second period then it will become an active forager too.


“They are managing a tradeoff between the rate at which they get food relative to the rate at which they lose water when searching out in the hot sun,” Gordon says. This foraging algorithm is very similar to something called Transmission Control Protocol (TCP), a system that regulates data traffic online by sending out small packets of information to work out the amount of bandwidth available. If there’s plenty of bandwidth available, then TCP makes sure that further data packets follow, but if there’s not, then the whole traffic flow slows down in order to conserve energy.

Other species have evolved their own algorithms for organising their colonies. Tree-dwelling turtle ants, for example, have worked out an algorithm for repairing their trail networks when their usual route between different nests is disrupted. Turtle ant colonies are divided between multiple nests that are connected by a constant flow of ants moving from nest to nest, but every now and then a falling branch or errant leaf will break this path.

When it comes to finding a new route around the obstruction, turtle ants employ a broad search strategy, trying out lots of different new routes at first, and gradually pruning them back until they’re left with only the most useful paths. For Saket Navlakha – a computational biologist who has worked with Gordon on her ant studies – the turtle ants highlight one of the innate advantages of biological algorithms. “Often in engineering we seek solutions that are highly efficient and that get the job done as quickly as possible, whereas for biology, efficiency is important but being robust, flexible and adaptive are as important as getting the thing done as quickly as possible.”

Read next What happened when I let algorithms run my life for a week What happened when I let algorithms run my life for a week

The turtle ant’s pathfinding algorithms might provide a useful model for robotic swarms, helping them devise new routes on the go, Navlakha says. In environments where resources are scarce, nature has done a great job at coming up with solutions that balance objectives against efficiency.


And it’s not just ants that can teach us how to devise better algorithms. Nature is littered with algorithms that could be applied to real-world problems. Navlakha has studied how the pipes that carry water and nutrients inside plants are built to balance utility and energy expenditure. This could give us a framework for building better subways and road systems, he says. “I think there are a lot of lessons that can improve the engineering world, but then these kinds of frameworks to understand algorithms and their properties is a way to better understand the underlying biology as well.”

But our access to nature’s algorithms may be under threat. Some of the most interesting natural algorithms evolve when species find themselves in extreme environments so they’re forced to come up with ingenious ways to access scarce resources, or navigate a treacherous environment. “Every environment gives you new constraints on an algorithm,” Navlakha says. “There are some species that can encode some very unique ideas.”

It’s these kinds of species that often find themselves most threatened by changes to their environment. Push a species too far and its algorithms may be lost to us forever. And ultimately, Navlakha says, that means it’s us humans that will end up missing out on the engineering lessons we might find within.

For Gordon and Navlakha, and other people working in the blooming field of computational biology, this lends an edge of urgency to their research. “I think some of these species might be doing very clever things that I think it's our job to find out,” Navlakha says. Now the race is on to uncover nature’s hidden algorithms before they’re gone for good.

How to follow WIRED on Algorithms

Bookmark our WIRED on Algorithms hub page where we’ll be adding new reports and stories throughout the week.


– How to block targeted advertising on Facebook, Google, Instagram and Twitter

– Google's Image search has a massive celebrity sexism problem

– Why does Facebook recommend friends I've never even met?