Simulating the emergent behavior of ant colonies
practicingruby.com
practicingruby.com
The Ruby-based simulator discussed in this article used Rich Hickey's Clojure ant simulator as a starting point: https://gist.github.com/spacemanaki/1093917
Hickey's simulator was perhaps a bit closer to what you are looking for. It only emits one type of pheremone, which it releases on a continuous basis.
In my simulation, I introduced two types of pheremones: one emitted when food was found, and another emitted when the home was found. In retrospect, I possibly could have continuously emitted the "food" pheremone when traveling outbound, and the "home" pheremone when traveling inbound. I can't remember if I tried that and ran into trouble, or just didn't think of the idea at the time I was building this.
I vaguely remember choosing to implement things this way because it eliminated the noise generated by ants wandering in circles endlessly, but I honestly can't remember why I decided to "improve upon" Hickey's simulator.
It's worth pointing out that though the behavior of the world is very artificial (the whole trail gets marked at once after a complete path is run), the behavior of the ants themselves still only relies on their immediate location. And because these ants don't know where "home" is, they're even dumber than real ants that actually do have some sense of direction.
Anyway, refinements on this simulator or links to other simulations that illustrate these ideas are absolutely welcome! I'd definitely update the article if we found a way to improve upon what I've done.
https://www.youtube.com/watch?v=VsHc91IhzdI
My ants also had no conception of where their home was located, their behavior is entirely pheromone driven. They can "read" pheromones from any adjacent cell.
They leave a pheromone every movement depending on which state they are in, either "find food" or "return food".
In my system, the pheromones have a strength. Whenever an ant touches the nest, his "nest pheromone" is at full strength (255). Each movement decreases the strength by 1. This sets up a natural gradient of nest strength for ants to follow. They also "deteriorate" each round as yours do.
A similar setup is used with food, such that a high food scent is created when they pick up food, and decreases in strength as they return to the nest.
So to find food, they try to move up a food gradient or down the nest gradient (away from the nest), while to return food they move up the nest gradient (towards the nest).
Their searching consists of a random walking into cells that have no nest scent, or following a food trail.
They have an energy cost for moving, and if it's too low they have to eat a piece of food. Returning a piece of food to the hill spawns a new ant. The lines on the right side show the population of each colony and the total food on the board.
From these extremely basic rules, they are very efficient at clearing the "world" of food.
This would cause lots of smaller weaker trails, and the occasional strong trail.
Ants out looking for food would follow trails with chances of deviating from the trail based inversely on the strength of the trail. Meaning food sources would get more attention than the random dead-end trails.