Boids Flocking Simulator illustration

Boids Flocking Simulator

Craig Reynolds’ boids model shows how the mesmerising motion of a flock emerges from three simple rules that every agent applies to the neighbours inside its perception radius: separation (steer away from crowding), alignment (match their average heading) and cohesion (steer toward their average position). A spatial hash grid keeps hundreds of boids flocking smoothly at once. Drag the weight of each rule and the perception radius to shift the swarm between a loose gas, tight murmurations and rolling waves. Toggle a hawk predator that hunts the local flock centre while the boids scatter away from it, and press and hold the pointer to attract or repel them. The edges wrap around, boids are drawn as oriented triangles tinted by heading, and an adjustable motion-blur trail traces their paths while a readout reports the boid count and frame rate.

Runs 100% in your browser — simulations are computed locally on your device.

Notes

  • Introduced by Craig Reynolds in 1987, boids was one of the first demonstrations that coordinated group motion needs no leader and no global plan — only identical agents reacting to their nearby neighbours.
  • Each boid steers by combining separation, alignment and cohesion; re-weighting these three forces alone reproduces flocks of birds, schools of fish and swarms of insects.
  • Real starling murmurations track a roughly fixed number of nearest neighbours rather than everything within a fixed distance (Ballerini et al., 2008), which keeps the flock cohesive even as its density changes.
  • Runs 100% in your browser — simulations are computed locally on your device.