Chapter 02 · Collective motion
The flock
At dusk, thousands of starlings turn together across the sky as if one animal were steering. None of them is.
In 1987 Craig Reynolds, a computer graphics researcher, wanted to animate a flock of birds. Scripting every bird's path by hand would have been hopeless, and moving the flock as one object looked wrong. So he wrote a small program for a single bird, made many copies, and let them loose. By 1992 techniques based on his model were animating the bats and penguins of Tim Burton's Batman Returns.
He called his birds boids. Each boid knows only what is happening close by. It has no idea how big the flock is or where it is going, and there is no leader.
The rules
Every boid looks at the other boids within a short distance of itself, its neighbours, and adjusts its heading a little according to three rules:
Separation. Steer away from neighbours that are too close, so you don't collide.
Alignment. Steer toward the average direction your neighbours are flying.
Cohesion. Steer toward the average position of your neighbours, so you don't get left behind.
The three pushes are weighted and added, the boid turns by that much, and every boid moves a step forward. None of the rules mentions the flock.
Take a rule away
The boids start out scattered. Within a few seconds they gather into groups that line up and merge. To see what each rule is for, drag its slider to zero.
No cohesion. The boids still line up and keep their distance, so they fly in loose parallel streams. But when a stream frays, nothing pulls it back. The flock thins out across the space, and neighbours each drops.
No alignment. The boids want to be near each other but have no reason to fly the same way. They collect into restless blobs that churn in place, and the alignment number drops close to zero.
No separation. Cohesion wins unopposed. Each group collapses into a tight knot, and the knots swallow each other until there's essentially one. Watch neighbours each climb toward 300: everyone can see everyone.
So the flock exists only in the balance between the rules. Separation and cohesion fight over spacing, and alignment turns a crowd into something that moves. The radius matters too. Shrink it to 10 or 15 and boids barely see each other, so they form small groups or none. Push it to the top and the flock becomes one big, slow, very orderly mass.
No leader, no map
Now chase the flock. Only the boids near the pointer see you and turn away. Their neighbours see them turning, and alignment makes them turn too. A wave of turning passes through the flock faster than any single boid could warn the others, and the flock splits and flows around you.
The flock behaves as if it had a plan, but no boid carries one. Its shape is what you get when each boid keeps making small corrections based on a handful of others, and the corrections spread.
The flock lasts only as long as the boids keep making it.
Measuring order
To measure how orderly a flock is, give every boid an arrow of length one pointing the way it flies, and average the arrows. If everyone flies the same way, the average has length 1. If they point in random directions, the arrows mostly cancel and the average is close to 0. Physicists call a number like this an order parameter. It is the alignment figure under Figure 1.
In 1995 the physicist Tamás Vicsek and his colleagues stripped the boid down further. Their particles all move at the same constant speed, and the only rule is alignment: at each step a particle takes the average heading of everything within a fixed distance, including itself. Then they added noise, a random nudge to each new heading.
With low noise, the particles start random and gradually agree. Aligned patches form and merge until the whole box drifts one way and the order parameter sits near 1. Nobody chose the direction, and Randomise will usually give a different one.
Now raise the noise slowly. The order wobbles but holds, until somewhere in the middle of the range it gives way and the order parameter falls to near zero. Turn the noise back down and order returns. A switch between two collective behaviours over a fairly narrow range of a setting is a phase transition, like water freezing. Here it happens among moving, self-propelled particles rather than molecules in equilibrium.
That difference matters. Take a flat sheet of tiny magnets, each free to point any way within the plane and each trying to point like its neighbours. It can never settle into true long-range order, because random jiggling always wins at large enough scales. The same year as Vicsek's paper, John Toner and Yuhai Tu used a continuum theory to show why flocks escape that limit. Roughly, moving particles keep swapping neighbours, which carries information across the flock far better than a fixed lattice can.
What real starlings do
Boids and Vicsek's particles find their neighbours by distance: everyone within a fixed radius counts. In 2008 a team in Rome including Michele Ballerini, Andrea Cavagna, Irene Giardina and Giorgio Parisi checked whether birds do the same. Using several synchronised cameras, they photographed starling flocks over the city and reconstructed each bird's position in three dimensions. Each starling turned out to interact with a roughly fixed number of neighbours, about six or seven, however far away they are.
They called this a topological interaction, as opposed to a metric one based on distance. It may matter when a flock under attack by a falcon stretches and compresses. With a metric rule, a bird whose neighbours drift out of range has nobody to follow. With a topological rule it always has six or seven, wherever they are, so the flock holds together through big changes in density.
You can try this in Figure 1. Drag radius down to about 15, and neighbours each falls below one as the flock loosens into stragglers. Now press neighbours: within radius so that it reads neighbours: nearest 7. The orange boid's circle stretches to reach its seventh-nearest neighbour and the count locks at 7. Within a few seconds the stragglers pull back into a flock.
The toggle shows a limit too. With seven neighbours each, the flock sometimes splits into groups flying side by side, because every boid's seven nearest can sit inside its own group.
The Rome group later found something that ties back to the sandpile. In starling flocks, each bird's deviation from the flock's average velocity is correlated with other birds' deviations, and that correlation doesn't fade over a fixed distance. It reaches across the whole flock, however big it is. Like the sandpile's avalanches, these correlations have no typical size.
The honest caveats
A boid flock that looks right is not evidence that birds follow these three rules. Reynolds tuned his model by eye, for animation, and many different rule sets produce something flock-like. Real birds fly in three dimensions, have momentum, see mostly to the front and sides, and react with delays. Which rules they use is settled by measuring them, as the Rome group did.
The model on this page also simplifies Reynolds' own. It is flat, its world wraps around, its boids see equally in every direction, and a neighbour counts fully or not at all. The weights and speeds were chosen to make the behaviour easy to see, not to match any species.
And "topological" does not mean a starling counts to seven. Six or seven is what the data are consistent with, and the mechanism behind it is a separate question.
What survives is the main point. Coordinated, apparently purposeful motion does not need a leader or a plan. It can come from many individuals each paying attention to a few others.
Try this
In Figure 1, set alignment to zero and wait for the boids to settle into churning blobs. Then slowly bring it back up, and watch for the moment a blob stops churning and leaves. That is a small version of the transition in Figure 2.
Next: Spots and stripes · All chapters