Collective Motion

Boids

Three local rules — keep your distance, match your neighbors, stay together — and a swarm becomes a flock.

Move your cursor over the flock to become a predator they scatter from. Tune the three steering weights to find the edge between a tight, marching school and a loose, gas-like swarm. Each boid is colored by the direction it is heading, so aligned groups share a hue.

What you're seeing

A few hundred identical agents — Craig Reynolds called them boids — each flying on its own. No boid leads; none can see the whole flock; there is no shared plan and no global rule. Every boid looks only at the handful of others inside a small perception radius around it and adjusts its own steering. From that purely local bookkeeping, the familiar shapes of collective motion appear: ribbons that bend as one, splits that re-merge, a flock that flows around an obstacle and closes behind it. The order is real, but it lives nowhere in particular — it is a property of the interactions, not of any individual.

The rule

Each boid computes a steering acceleration from three urges, each averaged over the flockmates within its perception radius:

Each urge is turned into a force the Reynolds way: compute the desired velocity, subtract the current velocity, and clamp the result to a maximum steering force. The three forces are summed (with the weights you control), added to velocity, and the velocity is clamped to a maximum speed before the boid moves. The world here is a torus — fly off one edge and you reappear on the other — and neighbor distances are measured across that wrap, so there is no special behavior at the seams. That is the whole model: no leader, no goal, no global coordination.

Why it matters

Boids, introduced by Reynolds at SIGGRAPH 1987, was a landmark demonstration that realistic group motion need not be choreographed. Before it, animating a flock meant scripting every bird; afterward, you specified a behavior and let the flock organize itself. The technique went straight into film — the bat swarms and penguin armies of Batman Returns (1992) used Reynolds-style flocking — and it remains a textbook example of agent-based modeling: many simple agents, local rules, emergent global pattern. It is also a clean case study in how a few interpretable parameters (the relative weights of three rules) sweep through qualitatively different collective states.

In the wild

Real flocks, schools, and swarms genuinely self-organize from local interactions — boids captures that essence — but the model is a behavioral caricature, not a derivation from animal biology, and a few honest distinctions matter:

So the lineage is honest: boids is the visual, behavioral ancestor; the science since has made the neighbor rule empirical (topological, not metric) and the dynamics quantitative (phase transitions, defined regimes).

Try this

References

  1. Reynolds, C. W. (1987). "Flocks, herds and schools: A distributed behavioral model." Computer Graphics 21(4) (SIGGRAPH '87 Proceedings), 25–34.
  2. Reynolds, C. W. "Boids: Background and Update." red3d.com/cwr/boids/ (model description and references).
  3. Ballerini, M., et al. (2008). "Interaction ruling animal collective behavior depends on topological rather than metric distance: Evidence from a field study." PNAS 105(4), 1232–1237.
  4. Couzin, I. D., Krause, J., James, R., Ruxton, G. D., Franks, N. R. (2002). "Collective memory and spatial sorting in animal groups." Journal of Theoretical Biology 218(1), 1–11.
  5. Vicsek, T., Czirók, A., Ben-Jacob, E., Cohen, I., Shochet, O. (1995). "Novel type of phase transition in a system of self-driven particles." Physical Review Letters 75(6), 1226–1229.