# Ant intelligence

And, termite intelligence.

## Building a termite nest

How termites do it:

• use pheromones
• metabolize bodily waste, which contains pheromones; this waste is what the mound is constructed of
• wander randomly, but prefer the direction of the strongest local pheromone concentration
• at each step, decide stochastically whether to deposit the current load of waste
• the probability of deposit increases with the local pheromone density and the amount of waste it is carrying
• a full termite will drop its waste even if there is no deposit nearby
• a termite that senses very high local concentration of pheromones will deposit whatever waste it is carrying (even a small amount)

## Ants finding food

How ants do it:

• five rules
• avoid obstacles (ants will not aimlessly push against a wall)
• wander randomly, in the general direction of nearby pheromones
• if no pheromones are sensed, execute Brownian motion (uniform distribution of choices)
• if holding food, drop pheromone at constant rate as it walks
• maybe follow a "nest beacon"
• if not holding food and finds food, pick it up
• if holding food and finds nest, drop food

The initial path will not be straight, but the tendency of ants to wander even in the presence of pheromones will generate short-cuts across initial meanders. Because pheromone paths have some breadth, they tend to merge together into a trace that becomes straighter the more it is used.

## Ants sorting things in a nest

This model is described in the article "Go to the ant": Engineering principles from natural multi-agent systems (PDF) by Parunak (1997).

This is the description from the article:

System Behavior An ant hill houses different kinds of things, including larvae, eggs, cocoons, and food. The ant colony keeps these entities sorted by kind. For example, when an egg hatches, the larva does not stay with other eggs, but is moved to the area for larvae. Computer scientists have developed a number of algorithms for sorting things, but no ant in the ant hill is executing a sorting algorithm.

Responsibilities The individual ant algorithm that yields system-level sorting behavior contains some behaviors similar to those in the path-planning problem.

1. Wander randomly around the nest.
2. Sense nearby objects, and maintain a short memory (about ten steps) of what has been seen.
3. If an ant is not carrying anything when it encounters an object, decide stochastically whether or not to pick up the object. The probability of picking up an object decreases if the ant has recently encountered similar objects.

In the emulation, the probability of picking up an object is ```P = (K+ /(K+ + F))^2``` where `F` is the fraction of positions in short-term memory occupied by objects of the same type as the object sensed and `K+` is a constant. As `F` becomes small compared with `K+`, the probability that the ant will pick up the object approaches certainty.

4. If an ant is carrying something, at each time step decide stochastically whether or not to drop it, where the probability of dropping a carried object increases if the ant has recently encountered similar items in the environment. In the emulation, ```P = (F / (K- + F))^2``` where `F` is the fraction of positions in short-term memory occupied by objects of the same type as the object carried, and `K-` is another constant. As `F` becomes large compared with `K-`, the probability that the carried object will be put down approaches certainty.

Integration As in path planning, the Brownian walk eventually brings the wandering ants to examine all objects in the nest. Even a random scattering of different items in the nest will yield local concentrations of similar items that stimulate ants to drop other similar items. As concentrations grow, they tend to retain current members and attract new ones. The stochastic nature of the pick-up and drop behaviors enables multiple concentrations to merge, since ants occasionally pick up items from one existing concentration and transport them to another.

The put-down constant `K-` must be stronger than the pick-up constant `K+`, or else clusters will dissolve faster than they form. Typically, `K+` is about 1 and `K-` is about 3. The length of short-term memory and the length of the ant's step in each time period determine the radius within which the ant compares objects. If the memory is too long, the ant sees the entire nest as a single location, and sorting will not take place.