Technique · Simulations

Flocking boids

Boids steering by separation, alignment and cohesion, drawn as a long exposure of streams, braids and swirls.

Flocking boids is a simulation that evolves step by step. Every piece on Synapse Drip is made from a recipe that layers techniques like this one, and you can change any of it in the Studio.

Good to know

  • Reynolds made an animated short called Stanley and Stella in: Breaking the Ice in 1987 with boids, and in 1998 he received an Academy Scientific and Technical Award for his pioneering work in computer animation.
  • A flock of starlings, called a murmuration, can hold tens of thousands of birds, and a turn started by a few birds at the edge can cross the whole flock within a second or two.
  • Real flocks work by watching neighbours, not by following a leader: there is no bird in charge, which is exactly the assumption of the boids model.
  • Craig Reynolds created boids in 1986 and described them in a paper at the 1987 SIGGRAPH conference; they were first used in a film in Batman Returns (1992), for the swarms of bats and the marching penguins.
  • A field study of starling flocks over Rome, published in 2008, found that each bird keeps track of about seven nearest neighbours, however far away they are, rather than all those within a fixed distance.

The mathematics

  • Each boid only reacts to others within 0.040 of the picture's height; the program sorts boids into a grid of cells that size, so a boid checks only nine cells and 1,400 boids cost about as much as a few thousand, instead of the millions of pair checks a naive version needs.
  • The three rules add up as forces: separation is a push away that grows as a neighbour gets closer, alignment pulls the velocity toward the average of the neighbours, and cohesion pulls the position toward their centre; speed is kept within a narrow band so the boids never stop.
  • The space wraps around like the screen of an old arcade game, a torus, so a boid that leaves on one side comes back on the other and a flock never runs out of room.

In art

  • Murmurations are a favourite subject of photographers and filmmakers; the long exposure here recalls the light-painting photographs of birds streaming across the sky.
  • Flocking rules are used in films, games and drone shows to make crowds, schools and swarms move believably without anyone choreographing each member.

More ways to use it

Related techniques

Reaction-diffusion · Cellular automata · Sandpile · Grain growth · Slime mould · Attractor cloud · Elementary automaton · Synchrony

All 90 techniques