Francisco Durão

Software Engineer

Ant Simulator

2015

Sample of walk animation

An ant simulator that mimics how ant colonies “measure” distances using pheromones.

In short, because ants produce pheromones and these pheromones vanish after a fixed time, longer trails tend to get a lower density of pheromones than shorter ones. Therefore, ants would rather follow shorter paths, which eventually makes longer ones disappear.

Program created in Unity. Scripts programmed in C#. Ants were modelled, rigged and animated using Blender.

AntSim Trails 1 AntSim Trails 2 AntSim Trails 3

Image 1 Image 2 Image 3

Fig. 1: Pheromones are represented as the beige dots. Nest as brown hill and food source as white square.

Image 1: Two pheromone trails were created a priori. Initially both trails start with the same density of pheromones, meaning ants have a 50/50 chance of selecting either trail.

Image 2: As time progresses and as ants carry food to the nest the density of pheromones on each trail starts to differ, thus changing the probability of selection of each trail.

Image 3: After some time only the shortest trail remains.

How Ant Simulator Works

Biology has always been one of my greatest passions, especially emergent systems. An emergent property of a system, is one that is not a property of any component of that system, but is still a feature of the system as a whole.

Ant colonies are a good example of an entity that, as a whole, presents a lot of emergent features. By using pheromones, an ant colony can “measure” distances, without any of the singular ants having any measuring capabilities.

[A 2006 study shows that ants DO have an internal sense of distance. However, I am working under the assumption that they do not].

My aim was to simulate the behavior where ants find the shortest path to a food source using an ant simulator where ants are created as simple as possible.

I modelled the ants as reactive agents: in each time step ants choose a certain behavior using pre-set condition-action rules. Figure 2 shows a representation of the internal process of an ant using a flow chart. In short, delivering food is the most important task, followed by grabbing food and following pheromone trails. If there are no trails near the ant, random exploration is then the chosen action. Ants use no form of direct communication. The only medium of communication between ants is the pheromone trails ants leave as they carry food back to the nest.

Exploration

When there is a pheromone trail near an ant, the ant will have to choose whether or not to follow it. Furthermore, if there are several pheromone trails nearby, the ant will have to choose which one it would rather follow.

To achieve this behavior the Boltzmann Distribution was used. The ant senses the pheromones around certain locations nearby. These locations are chosen randomly. Then it selects which location to follow according to the amount of pheromones. Locations with higher number of pheromones are more likely to be followed than those with lower number of pheromones. However, this is a stochastic process. Even if there are locations with a lot of pheromones the ant can still choose to explore randomly.

There are certain parameters inherent to the Boltzmann Distribution that can be tweaked, allowing for a very flexible model. This results in a simulation that can accurately portray the real-world: most ants will follow trails while some choose to explore on their own, trying to find new food sources.

BACK TO PROJECTS

Site designed and developed by Francisco Durão