# Ant colony algorithm

I am a student working on an ant colony simulator for a course project. The algorithm for it is (obviously) an ant colony algorithm. I know there are various forms of the algorithm but all of those were too mathematically detailed for us so we took an approach in which we have :

• An ant is born at a colony and must gather food from a source to sustain the colony.
• All ants are similar.
• The area in which the ant moves is a 1000x1000 grid, so every grid point serves as a valid point for an ant to occupy. Now, all the algorithms which I have come across involve treating vertices and edges separately but as we are restricting the ants movement to only four directions (up, down, left, right) I guess it doesn't matter where we put the pheromone.
• The grid points mentioned above store the pheromone.
• An ant drops pheromone only if it is carrying food.
• For an ant at a position (i,j), it decides where to move in the next step by taking the pheromone amounts on its four adjacent nodes into account in a simple probabilistic formula,i.e. the probability of traveling to a node is given by (pheromone amount at particular adjacent node) / (sum of pheromone amounts in 4 adjacent nodes).
• An ant cannot travel back to the position it just came from. It can only do so if it is at a site which has food or it is at its colony.

Now my concern is ( and what is actually happening in our program ) that when an ant FIRST reaches a position which has food and picks it up, then by the way our algorithm works, it can move anywhere! This is because it will only leave a pheromone trail, once it has the food and not before and as it is the first ant, there is no existing trail.

If the ant can move anywhere, the ants that reach the food source after it will also mostly tend to follow it.. EVEN IF it is not moving back towards the colony. This defeats the purpose of the entire algorithm.

So my questions are

• Is the above concern valid? If no, then why? If yes, then how to deal with it?
• Do we need to make some changes in our basic understanding of the algorithm to actually make it work?
• What are some other subtle yet important things that newbies like me may miss in this case?
• If I were building an ant colony, I'd have two types of pheromone marks: "regular", always left where an ant travels, and "food", only left by an ant carrying food. An ant moves towards greater concentration of "regular" pheromone if it's carrying food, otherwise towards "food" marks. Also I'd make ants "hungry" and "sated"; a hungry ant travels towards "food" marks but away from "regular" marks, in order to search for new food sources. (I'd also make the grid hexagonal, but it's not the point.) – 9000 Apr 13 '15 at 18:42
• While there are many variations, I think most of the ant colony algorithms assume that the ant can remember its way back home. IOW, it knows the nodes it visited already. The pheromone's come into play for the randomly travelling ants. – Dunk Apr 13 '15 at 18:50
• Ever play simant? – user40980 Apr 13 '15 at 18:52
• "I know there are various forms of the algorithm but all of those were too mathematically detailed for us so we took an approach in which we have..." Are you sure you're actually doing the assignment you were given if you couldn't understand the algorithms? – Doval Apr 13 '15 at 19:38
• @ Doval : We just have to do a project of our choice. We weren't constrained to a field in any manner. The course is an introductory one in C++. Our instructors just want us to have experience in software dev. – transistor Apr 13 '15 at 19:47