Boids: Flocking From Local Rules
No leader, no plan. Each boid watches only its nearby neighbors and obeys three steering rules. Dial separation, alignment, and cohesion and watch a flock cohere or fall apart.
Boids: Flocking From Local Rules
A flock looks choreographed, yet nothing choreographs it. In Craig Reynolds' 1986 model every boid sees only its near neighbors and follows three steering rules. The global pattern below is genuinely emergent: it falls out of those local interactions alone, with no leader steering and no path laid down in advance.
The order parameter is the length of the mean unit velocity: phi = |Σ v̂i| / N. It is near 1 when every boid points the same way and near 0 when headings are random. Right now it reads 0.000 (disordered). Start from a fresh seed with alignment at zero and watch it sit low, then raise alignment and cohesion and watch it climb as a single flock takes shape.
Each boid runs the same local computation every frame: gather the neighbors inside its perception radius, then blend three steering vectors. Separation pushes away from anyone inside the tighter inner zone so bodies do not pile up. Alignment nudges its heading toward the average heading of those neighbors. Cohesion pulls it toward their average position. Each vector is normalized to the max speed, the correction is clamped to a small max force, and the result integrates into velocity and then position.
No boid can see the whole flock and none is in charge. The coherent group is a fixed point of thousands of these myopic decisions interacting: alignment lets a heading spread neighbor to neighbor until a region agrees, cohesion keeps the region from drifting apart, and separation keeps it from collapsing to a point. Click the field to drop a predator; the boids that sense it inside its radius flee, the disturbance ripples outward through purely local steering, and the flock re-forms once it passes. Click again to remove it.
Seeded with a mulberry32 PRNG so Reset reproduces the same start. After Craig W. Reynolds, "Flocks, Herds, and Schools" (1987).