Birth of a Superorganism: Prototyping an Ant Colony Simulation Game

July 16, 2019

Five years ago when I made a prototype for an ant colony simulation game, an incredible phenomenon occurred. With only a few lines of code, my ants became an intelligent superorganism with advanced pathfinding capabilities.

What made such complex behavior possible with so little code?

The answer is pheromones. In the simulation, each ant was represented by a couple black pixels and alternated between two behaviors:

Follow red pheromones to food while leaving blue pheromones behind. Follow blue pheromones back to the nest while leaving red pheromones behind.

Though the logic was simple, when a few hundred ants performed these behaviors they achieved a form of collective intelligence, or hive mind.

There was no central brain; the ants were using pheromones to store, update, and share information through the environment itself.

While the ants foraged for food, they would form pheromone trails that other colony members could follow. Each time an ant traveled along a pheromone trail, the scent of the trail would be strengthened with more pheromones.

If a trail was too slow, it would not be reinforced with pheromones frequently enough and would eventually evaporate.

If a fast trail was discovered, the ants would be able to make frequent trips between the nest and the food source, strengthening the trail’s scent and drawing more ants.

After a few iterations, the slow trails would evaporate while the fast trails remained.

This method of pheromone-based foraging allowed the ants to find the optimal route to a food source in almost any situation.

If food was placed nearby, the colony would swiftly establish a bee-line foraging trail between it and the nest.

Barriers were then placed to obstruct the movement of the foraging ants, but they would circumvent it and find an alternate path.

When trapped in a maze, tendrils of worker ants would spread through every corridor until a food source was found, then food would be siphoned back to the nest by the quickest route possible.

And not only was the colony capable of solving complex pathfinding problems, but the pheromone networks they formed in the process produced some beautiful watercolor-like compositions reminiscent of De Stijl.

This prototype eventually became the inspiration for Antkeeper, a 3D ant colony simulation game in which you can paint pheromones to lead your ants to food or away from danger.

At the time of writing, Antkeeper is still in development. If you’re interested in playing the game or following its development, please subscribe to the Antkeeper mailing list or join the Antkeeper community!