How Three Rules Make a Flock

In 1986, Craig Reynolds showed that flocking — the swirling, splitting, regrouping dance of a thousand starlings — needs no leader, no plan, and no map. Just three local rules applied to every bird.

scroll to begin

Boids
80
Boids
Alignment
Clusters

A sky full of birds

Start with 80 birds placed at random, each heading in a random direction at a random speed. No organization, no structure — just noise.

Watch them for a moment. They drift aimlessly, pass right through each other's paths, oblivious.

Rule 1: Separation

Don't crowd your neighbors. Each bird looks at nearby flockmates and steers away from any that are too close. The closer the neighbor, the harder the push.

This alone prevents collisions, but produces nothing like a flock. The birds scatter.

Rule 2: Alignment

Match your neighbors' heading. Each bird looks at the average direction of nearby flockmates and steers to match it.

Now the birds begin to move in parallel streams. Local consensus propagates outward until large groups share a heading.

Rule 3: Cohesion

Steer toward the center of nearby flockmates. Each bird computes the average position of its neighbors and gently steers toward it.

This pulls loose streams into tight groups. The birds cluster.

All three together

With all three rules active, the birds form coherent flocks that wheel, split around obstacles, and rejoin. No bird knows the global pattern. Each one only sees its neighbors.

The flock is an emergent property — it exists at the group level but is coded nowhere.

The perception radius

Each bird only reacts to neighbors within a limited perception radius — shown here as a faint circle. Beyond this radius, other birds don't exist.

Information travels through the flock like a wave: a turn at the front propagates backward as each bird adjusts to its local neighborhood.

Introducing a predator

A red dot moves through the flock. Birds within range steer sharply away from it. Watch the flock split and reform around the threat — exactly what starling murmurations do with hawks.

No bird knows "the flock is splitting." Each bird just moves away from danger.

Reynolds' insight

Complex global behavior doesn't require complex individual behavior. Three rules, each operating on purely local information, produce patterns that look designed but aren't.

The same logic applies to fish schools, ant trails, traffic jams, and crowd dynamics. Order without a choreographer.

No leader required

There is no lead bird. No bird has a global view. Each boid applies the same three rules to the handful of neighbors it can see. Yet the collective result is a fluid, adaptive structure that responds to the environment as if guided by a single intelligence.

Reynolds originally built Boids for computer animation — his flocks looked so realistic that the technique was used in Batman Returns (1992) for swarms of bats and armies of penguins.

Order from chaos

Average alignment (how parallel the birds are) over time. Multiple runs starting from random initial conditions all converge to high alignment within seconds.

20 independent simulations. 80 boids, standard rule weights. Alignment measured as mean cosine similarity of heading vectors.

A phase space of behaviors

The three rule weights — separation, alignment, cohesion — define a space of possible collective behaviors. Turn up separation and the flock explodes outward. Turn up cohesion and the birds collapse into a dense ball. The sweet spot produces the flowing, lifelike motion we recognize as flocking.

The balance matters more than any single rule.

What each rule does alone

Cluster count over time with only one rule active at a time. Cohesion merges groups, alignment synchronizes them, separation breaks them apart.

80 boids per simulation. Each line shows the number of distinct spatial clusters over 300 frames.

Where Boids live

Reynolds published "Flocks, Herds, and Schools: A Distributed Behavioral Model" at SIGGRAPH 1987. The paper launched an entire subfield of artificial life and remains one of the most cited works in computer graphics.

Variations of the algorithm are used today in robotics (drone swarms), ecology (modeling migration), video games (NPC crowd movement), and architecture (pedestrian flow simulation).

Try it yourself

Adjust the three rule weights and watch the flock respond. Crank separation to scatter them. Max out cohesion to compress them. Find the sweet spot in between.

Flock
Alignment over time
Cluster count over time