How Ants Shaped Our Computer Algorithms
It begins with chemicals and ends with optimization algorithms. Three concepts, one ending.
Introduction
I promise I’ll get to the part about computer algorithms, but it will have to wait. I’m taking you on a journey, where the destination is computer algorithms. You’ll learn plenty more along the way.
Ants are (arguably) one of the most behaviourally complex living things on Earth. Ants form colonies, clean the nest, defend the nest, and take food back to the nest. You’ve probably seen this behaviour in action before. You walk on the street, and you see a congo line of ants. Perhaps they are currently infesting your home, eating anything they want to.

However, behind this completely ordinary behaviour of ants is something that is incredibly complex. People usually don’t think of it this way, but this behaviour is actually highly unusual. Think about it. There are a bunch of tiny insects with brains the size of a grain of sand scuttling after each other and working together to tackle problems.
Here’s an example of some very interesting behaviour coming from a species of ants called Burchell’s Army Ants (Eciton burchelli). These Army Ants regularly form large groups of ants that go out to forage together. These foraging “raids” contain many ants as they run about the forest floor, killing and eating everything alive that they come across.
Already, there are some questions to be asked: How do these Army Ants organize such large groups of ants and forage together? That would be the question I tackle in the next chapter.
Chapter 1: Ant Cologne™ and its Uses
What is Ant Cologne™? That’s a very good question! Ant Cologne™ is a silly name I invented for something actually very serious and scientific: Pheromones. Well, what are pheromones? Pheromones are a group of chemicals that usually convey some kind of simple message to certain organisms, like ants! These chemicals have a variety of uses, which is where the puzzle starts to click together as to how ants actually communicate.
See, there are two main types of pheromones: One for food, the other for alarm. There are also many other pheromones that aren’t as important as food or alarm pheromones, so I’m not listing them here.
Right now, we’re focusing on the food pheromones.

Food pheromones really relate to the question from the introduction. Food is an essential part of every colony, keeping everybody alive and also rearing the next generation of ants. However, food is tricky to get. Ants need to be as efficient with food as possible, in order to be able to compete with other insects. So, ants collectively devised a system to achieve a goal: instead of letting ants wander around aimlessly, rarely even touching food, this system would allow ants to gather en masse around food, turning wasted time into efficient food-gathering. Sometimes, large food items also need multiple ants to pick up, due to weight. And the system needs pheromones to function. Here’s how the system works.
Researchers studying African Big-Headed Ants (Pheidole megacephala) found how their system works. They found that two major pheromones are deployed at different times at the same food source to recruit other foraging ants to the food source. One is a long-lasting weak recruitment pheromone, deployed when trying to discover new food sources. The other is a short-lasting strong recruitment pheromone, used when currently eating up a food source. So that way, when the ants (less rarely, due to the long-lasting weak pheromone) find food, they can deploy the short-lasting strong pheromone to quickly gather large amounts of ants to the area.
Both of these pheromones, together, allow the workers to quickly travel towards the food source when discovered. A combination of these pheromones also allows the colony to track changes in the food source.
The combination of these two pheromones is part of the reason that African Big-Headed ants outcompete other native species.
Wow! So, to summarize, ants deploy many different types of pheromones to communicate with other ants in a variety of ways, including, but not limited to, gathering food. Now, if you remember, in the introduction I said this:
“Think about it. There are a bunch of tiny insects with brains the size of a grain of sand scuttling after each other and working together to tackle problems.”
And make no mistake, I chose those last few words deliberately. “to tackle problems.” Yes, you read that right, ants can tackle problems. We’re one step closer to optimization algorithms, don’t worry.
Chapter 2: Swarm Intelligence
Swarm Intelligence is one of the most complex behaviours of any organism. It involves the collaboration of so many different individuals, made possible by pheromones. It’ll make sense in a moment.
At some point in time in 2016, a group of researchers were carrying out an experiment. This is one of those experiments that might make it into some kind of niche scientific take on the popular TV shows Beast Games or The Amazing Race (both are high-stakes reality shows — search that up if you don’t know what it is).
The objective was simple: to test how well the ants worked together towards shared goals. But there was a catch. The ants had to navigate a series of obstacles in order to achieve the goal.
Meet the test subjects: Longhorn Crazy Ants, aka Black Crazy Ants (Paratrechina longicornis).The setup for the experiment was quite interesting. First, a large piece of tuna was placed near the entrance of the ant nest. The tuna, a valuable source of food, was too big for the ants to carry alone, so they had to do it together. The tuna was basically the million-dollar prize at the end of high-stakes reality shows1. The researchers, to test the ants cooperation abilities, placed three obstacles between the tuna and the nest entrance. In order to get the tuna back to the nest (because ants usually carry food back to the nest if possible) they would have to cross these obstacles. I really like how the researchers used Lego bricks to construct these obstacles.
The first was a wall. The wall would block the shortest path to the nest, making the ants collectively take one of the equally long paths left or right to go around the wall.

The next obstacle was a dead end. Basically, it was the same as the wall, except the ants couldn’t carry the tuna left or right to pass this - they need to go backwards and go another way.
The final obstacle is a bit cruel in my opinion. The ants are first lured into carrying the tuna into a false dead-end, because it isn’t a dead end. It’s a bit like in certain movies, to elicit fear, when a bunch of people enter some kind of haunted house and the door behind them closes. The final obstacle is just like that. It’s a dead end that becomes a trap. There is no way for the ants to scale the wall and carry the tuna with them. At this point, they need to recognise defeat and give up. They have to leave the tuna behind and attend to other duties. They win if they surrender, and they will lose if they keep trying.
The researchers conducted the experiments. The results were very surprising.
The researchers measured a variety of things. Of these things, I will talk about three here: ability to reach consensus, correlation between more ants helping and efficiency, and how quickly the Black Crazy Ants passed the three obstacles.
Surprisingly for me (and probably for the researchers as well), the ants reached consensus really quickly. More often than not, they didn’t stall, and uniformly agreed on which way to go. They uniformly agreed on which way to go. As humans, we may bicker and argue about which way may take the least time and effort. The ants skipped that step and already started moving. And that takes communication. Perhaps they could use pheromones to help them decide. Perhaps they could communicate in some other way, like antennal contact or vibrating the ground. I don’t know.
Do more ants that help actually contribute to the group? Or, like humans, too many ants causes confusion and not knowing which way to go? Nope! There is a very apparent positive correlation between another ant helping and increasing overall efficiency. This means that the more ants join the party, the more efficient the group is! The researchers also observed that whenever a new ant joined the party, the party would make a sharp turn (in a better direction). This could be due to the fact that new ants often had more information on the entire dynamic of the situation, and could better solve the problem. As a result, the old team carrying the tuna would conform to the new ant’s direction of movement. This is a huge part of their success at most of the obstacles.
How did the ants fare at each obstacle, then? The wall obstacle was passed quite easily. Similarly, the dead end was also maneuvered easily. It was at the trap, the final obstacle, that the ants succumbed. Even though activity slowly decreased around the tuna at the trap, there was still a lot of stalling, the ants generally didn’t “pass” this test. The ants refused to give up, leading to their defeat.
I recommend reading the paper yourself. It was truly amazing! https://doi.org/10.1242/jeb.143818
The ants solved complex problems. They communicated, complied, led, and went through most of the obstacles. This behaviour is called Swarm Intelligence. And ladies and gentlemen (and people who are both, or neither), I present to you the epiphany of it all: Swarm Intelligence optimization algorithms, where we, once again, copy the exact thing that made us. Nature itself.
Chapter 3: Ant Colony Optimization (ACO)
Time to answer the question you have all been asking: How did ants shape our computer algorithms? Good question. To begin, we must first understand what an algorithm is. A computing algorithm tells a computer exactly how to process information, and what it should do. Some really famous algorithms are social media algorithms, algorithms that usually are made to make you stare at that social media platform for as long as possible. For YouTube, this may involve analyzing what you usually watch, and for something like the home feed of Substack, that may involve showing you notes (the social media aspect of Substack) that are similar to ones you liked before, or from people you follow. Within the huge umbrella of computing algorithms, where are Optimization Algorithms. Optimization algorithms find the best possible solution to a complex problem by minimizing or maximizing something. For example, minimizing cost, maximizing profit.
Within optimization algorithms, there is a further subgroup. It is called Swarm Intelligence Algorithms, or SI algorithms for short. These algorithms are inspired by nature — ants, birds, bees, wasps, fish, termites, and many more. These SI algorithms solve complex optimization problems by having many “particles” move around in a decision space. These particles are basic agents that can indirectly communicate with each other.
And, within SI algorithms there are two algorithm types that are currently the best: Ant Colony Optimization and Particle Swarm Optimization. And in my opinion, the ants deserved their ranking in the SI algorithm hierarchy.
Ant Colony Optimization (ACO) was inspired by pheromonal behaviour in ants.
ACO started out being known as Ant System (AS), which was the first ACO algorithm ever made. After Ant System, loads of effort went into developing ACO algorithms, because of how great it was. ACO went on to be applied to problems such as Assembly Line Balancing, a very complex problem, with the goal being to be able to give each workstation of the assembly line in factories the same amount of work. This makes the process much more efficient. ACO has also been applied to DNA sequencing and lots more problems out in the world. How much this algorithm helped us is immeasurable.
If you think about it, optimization algorithms and ants living their day-to-day life isn’t that different at all. Both have the same goal of solving a problem as efficiently as possible, with many little “agents” that can communicate indirectly. Many of the most unnatural things hide their solutions in nature. We just have to look a little closer. Or, in this case, just look at the ground.
Sources:
Franks, N. R., & Fletcher, C. R. (1983). Spatial patterns in army ant foraging and migration: Eciton Burchelli on Barro Colorado Island, Panama. Behavioral Ecology and Sociobiology, 12(4), 261–270. https://doi.org/10.1007/bf00302894
Dussutour, A., Nicolis, S. C., Shephard, G., Beekman, M., & Sumpter, D. J. (2009). The role of multiple pheromones in food recruitment by ants. Journal of Experimental Biology, 212(15), 2337–2348. https://doi.org/10.1242/jeb.029827
Wilson, E. O., & Regnier, F. E. (1971). The evolution of the Alarm-defense system in the formicine ants. The American Naturalist, 105(943), 279–289. https://doi.org/10.1086/282724
McCreery, H. F., Dix, Z. A., Breed, M. D., & Nagpal, R. (2016). Collective strategy for obstacle navigation during cooperative transport by ants. Journal of Experimental Biology, 219(21), 3366–3375. https://doi.org/10.1242/jeb.143818
Ciaralli, S., Roessingh, P., Barbero, F., Groot, A. T., & Casacci, L. P. (2026). Multimodal signal detection in ants: Evidence for lateralization in antennal electrophysiological responses. Journal of Insect Physiology, 173, 105035. https://doi.org/10.1016/j.jinsphys.2026.105035
Abdulghani, B. A., & Abdulghani, M. A. (2024). A comprehensive review of ant colony optimization in swarm intelligence for complex problem solving. Acadlore Transactions on AI and Machine Learning, 3(4), 214–224. https://doi.org/10.56578/ataiml030403
Dorigo, M., & Stützle, T. (2010). Ant Colony Optimization: Overview and recent advances. International Series in Operations Research & Management Science, 227–263. https://doi.org/10.1007/978-3-319-91086-4_10
You can probably guess what I watch on TV.





