Skip to content
Boris Truyens

Seven neighbours

A simulator of bird flocks and fish schools in the browser. Thousands of animals, no leader, and one rule that explains everything.

Murmur, starlings over the lake at sunset. 3,500 birds, live in the browser.
Murmur, starlings over the lake at sunset. 3,500 birds, live in the browser.

Anyone who has seen a murmuration of starlings never forgets it. A cloud of thousands of birds that shifts shape like smoke, splits around a falcon and flows back together, without a single bird colliding. It looks as if there is a plan. There is no plan.

The rule

Italian researchers filmed starlings over Rome in 3D and found something strange. A starling does not pay attention to every bird within a certain distance. It watches a fixed number of neighbours, six or seven, however far away they are. That is called a topological rule, and it explains why the flock does not fall apart when it stretches: every bird stays connected, even as the density changes.

In Murmur every bird follows exactly that rule. Keep your distance from your neighbours, fly the way they fly, stay close. With a blind spot behind you. That is all. Try it yourself:

Put the slider at zero and you see noise. From two or three neighbours, small groups form. Around seven, something happens that no rule describes: groups start to move as one thing. That is emergence, behaviour that lives in no single part, only in the whole.

Every species, a different rule

It became a study in how little difference you need for very different behaviour:

  • Geese fly in a V. Each goose seeks the spot diagonally behind the bird ahead, where the upwash from its wingtip carries her, and beats her wings in the same rhythm. The tired leader drops back and is replaced.
  • Goldfinches fly in bounds: a few wingbeats, then wings tucked, so the whole group rises and dips.
  • Jackdaws fly in pairs, wing to wing. The young start single, court each other in tail chases and pair up.
  • Sardines pull together into a ball when a tuna hunts, and burst open like a fountain where it passes through.
  • Barracuda turn in a slow tornado: each fish circles the school’s axis and keeps to its own layer.

Barracuda in a turning column above the reef

Sound without a score

There is also a soundtrack that writes itself, made with Strudel, a language for live-coded music. Each species has its own mood: a mode, a slow chord cycle, a melody that picks random notes from the scale. Wind as filtered noise in the sky, a low rumble under water. Switch species and the music changes mood.

Why this is here

No libraries, no build step. Pure WebGL2 and plain JavaScript, built in two days. It runs as the background on my screen in “wallpaper mode”: the interface disappears and every few minutes the view drifts to another species.

But what stays with me is the link to the workshop. A CNC machine has no “plan” either. It executes line by line, locally, without an overview. The overview lives in the rules someone chose. A flock of starlings is a program nobody wrote, and yet it works.

Watch the flock at birds.truyens.pro →

Where this leads

This project shares threads with others. Follow one.