In this simple javascript, 'ants' move randomly within a predefined bounding box until one of them stumbles upon some 'food' in the south-east corner of the page. The ants then consume the food source until their capacity is reached and then deposit the food in the nest. When the food source is depleted, the ants resume their random wondering behaviour.

The purpose of this script was to experiment with javascript/dom animation - frames are achieved via the setTimeout(function, n) function. It appears that firefox allows for a maximum of 60 calls to this method per second (60 fps) increasing with browser activity, while IE allows for upto 100 calls per second and thus smoother rendering.

There is a possiblity of implementing more realistic behaviour via a pheromone matrix, in which the ants communicate paths with each other indirectly by leaving a degrading chemical (stigmatic) footprint on the map.

back