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:
- Separation — steer away from boids that are too close, to avoid collisions and crowding. This acts only at short range and grows stronger the nearer a neighbor is.
- Alignment — steer toward the average heading (velocity) of nearby flockmates, so the group tends to move in a common direction.
- Cohesion — steer toward the average position of nearby flockmates, so boids drift toward the local center of the group rather than wandering off.
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:
- Starling murmurations. The STARFLAG study (Ballerini et al., 2008) reconstructed real flocks in 3D and found birds interact with a roughly fixed number of nearest neighbors — about six or seven — rather than with everyone inside a fixed distance. This topological interaction keeps the flock cohesive even as it expands and contracts; the classic boids rule, by contrast, is metric (a fixed-radius perception, like the one above).
- Fish schools. Couzin et al. (2002) showed that varying the size of the attraction/alignment zones moves a model group between distinct collective states — swarm, torus (a rotating mill), and parallel motion — and that real fish schools occupy these regimes, sometimes switching abruptly between them.
- Physics of flocks. Vicsek et al. (1995) distilled alignment to its minimum — point particles that simply average their neighbors' headings plus noise — and found a genuine phase transition from disorder to collective motion, launching the physics of "active 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
- Turn cohesion and alignment to zero and raise separation: the boids spread into a uniform gas that fills the space and never groups.
- Now raise alignment alone — the gas starts marching in a shared direction without clumping. Add cohesion and watch discrete flocks condense out.
- Shrink the perception radius: small neighborhoods fracture the flock into many independent bands; large ones pull everything into one super-organism.
- Move your cursor through a dense flock to play predator — notice how the disturbance propagates outward as a wave and the flock closes back up, exactly as a startled school does.
References
- Reynolds, C. W. (1987). "Flocks, herds and schools: A distributed behavioral model." Computer Graphics 21(4) (SIGGRAPH '87 Proceedings), 25–34.
- Reynolds, C. W. "Boids: Background and Update." red3d.com/cwr/boids/ (model description and references).
- 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.
- 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.
- 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.