Playground · Boids
Boids & flocking
No boid knows the flock exists. Each just follows three simple rules about its neighbours — yet together they produce the lifelike swirl of a flock of starlings. Emergence: complex behaviour from simple local rules. Tune the rules and watch the swarm change.
How it's built
Craig Reynolds' 1986 "boids" model in vanilla JS on a <canvas>. Every frame, each boid
looks at neighbours within a radius and computes three steering forces — separation
(push away from those too close), alignment (match their average velocity) and
cohesion (drift toward their centre) — blended by the sliders above. There's no leader
and no global plan; the flock is pure emergence.