Three rules. One flock.
You don't animate the flock. You write the rules for a single bird — then run
many copies.
The flock is a side effect.
Craig Reynolds published this trick at SIGGRAPH in 1987. Before boids, animating a flock meant scripting every bird's path by hand. Reynolds' insight was don't — write the rules for one bird and run many copies. The method went straight into production: the swarming bats in Batman Returns (1992), the wildebeest stampede in The Lion King (1994), a Scientific and Engineering Academy Award in 1998. It's probably the most-reimplemented agent-based model in existence. And the whole thing is three rules, each one about what a bird does with the birds it can see.
The lab · pick a regime, then try turning a rule off
drag inside the field to play predator · press space to pause
Regimes
The three rules
Finer controls — perception, flight, view
Space & creature
Perception
Flight
View
What the three rules actually say
Each boid sees only its neighbours — birds inside a vision radius, within a field of view (its own eyes don't look straight behind). From that handful of visible neighbours, three rules each propose a direction to steer:
- Separation. Push away from any neighbour that's too close. The force grows sharply as the distance shrinks — Reynolds originally used 1/d². Range: small, maybe a fifth of the vision radius.
- Alignment. Steer toward the average heading of neighbours. Range: medium.
- Cohesion. Steer toward the average position of neighbours — the local centre of the flock. Range: long.
Short-range repulsion, mid-range heading match, long-range attraction. Weighted sum. The acceleration is clipped to a maximum force; speed is clipped to a range; and that's it. There is no rule in there that says "stay 2 body lengths from your neighbour" — yet watch the nearest neighbour readout. It settles at a stable spacing you never told the model to produce. That's emergence.
Four regimes, one set of rules
The same three rules, with different weights and ranges, produce visibly different collective behaviours. Each preset above is a measured parameter set:
- Flock. The canonical setting. Polarization near 1.0, spacing stable at a few body lengths. The thing you expect birds to do.
- Swarm. Strong cohesion, weak alignment. A dense cloud that mills about without going anywhere — polarization drops to around 0.15, but the group stays tight. Mosquitoes and gnats look like this.
- Mill. Wide turning circle (low turn force) plus firm cohesion. The group closes into a rotating torus around an empty centre — watch the rotation metric, not polarization. Real fish and army ants do this.
- Tunnel vision. A narrow field of view. Birds can't see what's beside or behind them, so the flock stretches into restless lines instead of coherent clumps.
The 2008 Rome starling result
Everything above assumes a metric rule: "I pay attention to anyone within distance R." But that creates a problem — if the flock thins out, each bird sees fewer neighbours, so cohesion weakens, and the flock thins further. It should fall apart. Starling murmurations don't fall apart. Why?
An Italian team led by Andrea Cavagna and Irene Giardina took stereo photos of real starling flocks over Rome's Termini station between 2005 and 2008, reconstructed each bird's 3-D position, and asked: how many neighbours does each bird actually track? The answer was about seven — a fixed count, not a fixed distance. That's "topological" interaction. Switch it on in the Finer controls (the "Count neighbours, not distance" box) or load the Starling preset, and the flock holds together regardless of how spread out it is.
Where boids actually went
The direct uses are the famous ones — the bats in Batman Returns (1992), the wildebeest stampede in The Lion King (1994), countless games and movies since. But the idea travelled further:
- Agent-based modelling in general. Boids is the opening move. The proof-of-concept that collective behaviour emerges from local rules — the move that Schelling, Life, voter models, and everything downstream build on.
- Swarm robotics. Drone swarms and warehouse robots use variants of these rules so the whole fleet behaves without a central planner.
- Crowd simulation. Pedestrian flows, panic evacuations, concert crowds — different weights, same skeleton.
- Autonomous driving. Each car as a boid with the three rules plus a lane-keeping force gives you traffic flow for free.
Related models
- 🎮 Life & Local Majority — the other canonical "simple local rules → surprising global behaviour" demonstration, but on a grid instead of in continuous space.
- 🟦🟧 Schelling segregation — same family (agents following local rules on a shared space), different outcome: mild individual preferences producing strong global patterns.
- 🏔 NK rugged landscape — once you have a flock of searchers, the question becomes which landscape they're climbing. Boids on an NK surface is the "search as flocking" story.