Ant Colony

For this project I attempted to replicate an ant colony optimization algorithm combined with a termite algorithm, with opposing ant colonies. After many many hours of work in conceptualizing and attempting to execute the process, I ended up with a partial finish:


I created a flocking style algorithm for ants moving in a somewhat random direction, by adding all previous movements in an array and finding the median in order to create a more logical random movement, in the same way ants move forward forward directional if, etc. Here is the first construction of the ant random movement – the movement is different when near the colony than out in the “field”, as the ant would be more likely to move randomly to find food while in the wild than near home.

The red dots are food, the black sketches are ant trails.

I then created an array of food and ants in order to create collision detection between the two, so that the ant would detect the food and return home. I created another ant array for “ant_alert” that would spawn new ants at the detect food location and return home. This proved to be quite difficult (in learning about passing values, etc.) and I spent a considerable amount of time:

I then tried to create a reverse iterator through a vector of a “successful” path to find food, so that the ant could trace the origin home and add a scent trail to the path so other ants would follow this successful path. The scent trail I created only added to one food path, but never following the ant all the way back home. I wasn’t able to get past this part, but I have learned A LOT more about OF during this wonderfully excruciating process. I still want to create scent trails that fade over time so that the fastest path can be found, but I think I need to conceptualize the logic process more.

Related projects:

Anon Tweets
Coding Adventures
People's Skype
Social Cooking App