Ants

a) ants are cute

b) ants are super interesting how they optimise large scale problems (like finding food)

So, following on from my flocking experiments (although hopefully a bit simpler) I’m mucking around with ant hunt algorithms.

The basic gist of how ants find food and tell their buddies where it is is – they walk about, leaving pheromones behind them. ┬áIf they find food, they then follow their own path back to the nest, strengthening the path. As the other ants are walking about, they’ll tend to follow a stronger (more smelly) path than a less smelly one.

This is all really rather cool. I like the idea of second-order control. You do things to the environment to try and┬áimprove the ants’ behaviour, in order to achieve a goal. Should be fun.

Ok. So I have the ants appearing, walking around randomly, and (when they reach the edge of the screen) retracing their path back to base and dying. Awesome. Their trail gets printed out – which is kinda cool, so you can see where they go. There’s an ugly big bit of apparently unidentifiable food (it was supposed to be a sweet, dammit, time for a new image) in the middle of the screen.

Next:

  1. Make previous paths influence path choice (ie, if there’s a strong pheromone laid down, other ants will follow it)
  2. Make the “found the food!” thing a thing

The second one is trivial. The first… a little more interesting.

Ha ha. So, I’m making the ants a bit smarter – they’ll smell a pheromone trail if they run over it, plus run less distance away when they’re following a trail. Previously they’d just target roughly the same direction (but a bit finer tuned). The flipside is, they’re now behaving like maniacs. Ha ha.

play