Craig Reynolds' Boids algorithm shows how three simple rules — separation, alignment, and cohesion — produce the complex, lifelike flocking behaviour seen in birds, fish, and insects.
Three rules govern each agent: avoid neighbours (separation), steer toward the group's average direction (alignment), and move toward the group's centre (cohesion). From these local interactions, complex flocking patterns emerge globally.
Drag the sliders to adjust each rule's weight. Increase cohesion for tight flocks, separation for spread-out swarms. Change speed or add wind to see how the flock responds.
The Boids algorithm was published by Craig Reynolds in 1987 and was used in the film Batman Returns (1992) to simulate bat swarms — one of the first uses of AI-driven extras in cinema.