Swarm Bots

Agent Algorithm

A swarm agent looks at all the other agents he can see and selects the closest ones to follow. He then averages the velocities of his selected neighbors and accelerates in that direction, with a little bit of randomness added.


neighborsToFollow = selectNeighbors(visibleAgents)
adjustedAverageVelocity = averageVelocities(neighborsToFollow) *
                         (1 - randomizationFactor)
randomization = random direction * randomizationFactor
acceleration = adjustedAverageVelocity + randomization

Observed Behavior

This really is the simplest algorithm that will produce "life-like" behavior. The agents move around in swarms, at least until a wall stops them. The sliders vary the behavior in many different ways.

Unchecking "Choose Neighbors by Proximity" will change the algorithm to select random neighbors to follow.

The Applet

If you see this, you need to either enable java, or install the Sun Java Virtual Machine in your browser. To do so, click here.

Source Code

Back to the Applet Bots Home
The official version of this file is at applet-bots.sourceforge.net