Flocking and the Flock Vortex

A flock of starlings turns as one, yet no bird leads it and no bird sees the whole flock. Each one reacts to a handful of neighbours, and the shape of the flock comes out of those local reactions. This page explains the three rules behind the Flock Vortex, why seven neighbours, how a random scatter becomes a rotating ring, and what happens when a hawk arrives.

A flock of 600 birds circling a roost in one ring, each bird coloured by the direction it flies
A flock of 600 birds circling a roost in one ring, each bird coloured by the direction it flies

No leader, no map

Starlings over a reed bed, sardines in a bait ball and locusts on the march all move as one body, but there is no conductor. Every animal reacts only to what is close to it, and the pattern of the whole group emerges from those local reactions. Scientists call this collective motion or self-organisation.

The Flock Vortex lets you watch it happen. Every bird runs the same short program. It does not know where the flock is, how big it is, or where the middle of the ring will be. All the structure you see is produced by birds watching birds.

Three rules

In 1986 the computer graphics researcher Craig Reynolds showed that three steering rules are enough for a convincing flock. He called his simulated birds boids.

Separation: steer away from neighbours that come too close, so the birds do not collide.

Alignment: turn toward the average direction of the neighbours, so the birds fly the same way.

Cohesion: steer toward the average position of the neighbours, so no bird drifts away.

In the app each rule has a slider, and 1 is the standard weight. Every bird also flies at about the same speed and can only turn so fast, as a real bird can. A little random wobble keeps the flight from looking mechanical.

Seven neighbours, not a radius

Reynolds' boids reacted to every flockmate within a fixed distance. Real starlings seem to work differently. In 2008 the StarFlag project, led by physicists in Rome, filmed starling flocks with several cameras and rebuilt the position of every bird in three dimensions. Each bird turned out to react to about six or seven others, its nearest neighbours, wherever they happened to be, not to all birds within a certain range.

This is called a topological interaction, and it has a practical advantage: when the flock stretches out or squeezes together, every bird still has the same number of neighbours to follow, so the flock does not fall apart. In the Flock Vortex each bird watches its 7 nearest neighbours by default. Neighbours watched changes that number.

One bird joined by lines to its 7 nearest neighbours, inside a dashed circle through the furthest of them
One bird and the 7 neighbours it follows. Birds just outside the circle count for nothing.

How a scatter becomes a ring

In The Vortex, 600 birds start at random places, each flying its own way. Nothing pulls a bird to the middle: inside the roost's circle, with a radius of 200 px by default, a bird simply flies on. Only a bird that strays further out turns for home.

Turning back at the edge, a bird drags its neighbours round with it through alignment, and they drag theirs. Small groups that happen to circle the same way grow, groups that circle the other way are pulled round, and within seconds to half a minute the whole flock circles the roost in one direction. Which direction is chance: run it again and the ring may turn the other way.

This rotating ring is called a mill or a torus. Fish schools form it, and so do army ants that lose their trail and march in a circle. Iain Couzin and colleagues showed in 2002 that the same model can give a loose swarm, a mill or a flock that flies in one direction, depending only on how strongly the animals align.

Three moments of one flight: a random scatter at 0 seconds, a swirling crowd at 2 seconds, and one rotating ring at 10 seconds
The same 600 birds at 0, 2 and 10 seconds. The dashed circle is the roost's radius of 200 px.

Measuring the ring

The Ring number in the corner of the app measures how much the flock circles its own middle the same way. For every bird it takes the part of its flight that goes round the middle, counts it as plus or minus depending on the direction, and averages over all birds. Birds flying every which way give 0%; every bird circling in the same direction gives 100%. A random scatter starts near 0% and a settled vortex sits at about 98%.

The sliders show which rule makes the ring. Set Alignment to 0 and the ring never forms: birds still turn back at the edge, but half of them circle one way and half the other. Set Cohesion to 0 and the ring still forms, because the roost already holds the flock together. Set Neighbours watched to 20 and the flock stops milling: every bird follows so many others that the whole flock flies as one block, all birds pointing the same way, and the block itself travels round the roost.

The hawk and the selfish herd

In Flock vs Hawk the birds fly through a world without edges, and after a few seconds a hawk arrives. It flies faster than any bird but turns more slowly, and it goes for a bird that is close and on its own. A bird that sees the hawk near flees: it speeds up a little and turns sharper. Its neighbours follow it, their neighbours follow them, and a wave of escape runs through the flock, often splitting it in two around the hawk.

In 1971 the biologist W. D. Hamilton described the selfish herd: an animal in a group is safer than one alone, and safest in the middle, because a predator meets the animals on the edge first. Real raptors such as peregrine falcons attack starling murmurations in the same way, by trying to cut a bird out of the flock. Pick a bird in the app and watch whether staying with the crowd keeps it alive.

A hawk diving at a flock of birds against a sunset sky, the flock bending away and splitting around it
The flock bends away from the hawk and splits around it.

What the model leaves out

Real flocks fly in three dimensions, and the Flock Vortex flies in two. Its birds have no wings, no energy to spend and no blind spot behind them; they all fly at nearly the same speed and all follow exactly the same rules. Real starlings differ from bird to bird, and no two flocks are the same. The model is not a copy of a flock. It shows how little a flock needs: three rules and seven neighbours are enough for a ring, a wave and an escape.

Explore it in PictorX

Open the Flock Vortex to watch The Vortex form, or switch to Flock vs Hawk and tap a bird to follow it. Change Separation, Alignment, Cohesion and Neighbours watched while the flock flies, make the roost bigger or smaller, colour the birds by heading to see the ring rotate, and press Start over for a new scatter. Record a video, save a PNG, or open the picture in the PictorX editor with the sky, the roost, the trails, the flock, the hawk and your bird on layers of their own.

Frequently asked questions

What are boids?

Simulated birds that follow Craig Reynolds' three rules of separation, alignment and cohesion, from his 1986 model. Boids have been used for flocks, herds and crowds in films and games since the bat swarms and penguin armies of Batman Returns in 1992.

Why do real starlings flock?

The most widely accepted reason is safety: a bird in a dense flock is harder for a falcon to single out, and many eyes spot a predator sooner. Murmurations are most often seen at dusk, just before the birds settle at their roost for the night.

Does the ring always turn the same way?

No. Which way it turns depends on how the birds happen to start. Press Start over a few times and you will see both clockwise and counter-clockwise rings.

Is this the same as the Vicsek model?

It is a close relative. In 1995 Tamás Vicsek and colleagues studied particles that only align with their neighbours, with some noise, and found that the whole group suddenly starts moving together when the noise drops below a threshold. The Flock Vortex adds separation, cohesion, a limited turning speed, the roost and the hawk.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Try Flock Vortex