School of Fish & Predator
300 boid-driven fish school with separation/alignment/cohesion. A
predator sweeps through periodically, scattering
the school before it regroups.
Drag to orbit · scroll to zoom.
ℹ Details ▾
Each fish follows the classic
boids algorithm devised by Craig Reynolds in 1986: three simple local rules
— separation (avoid crowding close neighbors), alignment (steer toward the average heading of nearby
fish), and cohesion (steer toward the average position of nearby fish) — combine to produce lifelike,
emergent group motion with no central controller. Real fish school for several survival reasons: it dilutes
individual predation risk and confuses attackers ("predator confusion"), improves hydrodynamic efficiency by
exploiting neighbors' wake, and increases the chance of spotting food or threats. When the predator sweeps
through here, the school scatters explosively then re-coheres, mirroring how real schools react to an attack.
- Reynolds' original 1986 boids model used exactly these 3 rules to reproduce flocking/schooling behavior.
- Real schools can range from a few dozen fish to super-schools of many millions (e.g. herring, sardines, anchovies).
- Individual fish react to neighbor movements in roughly 15–100 milliseconds — fast enough for a "wave" of turning to ripple through a school almost instantly.
- Schooling species typically track ~4–7 nearest neighbors to decide their own heading, not the whole group.
- Predators (like tuna or dolphins) often attack schools by isolating and herding a small sub-group, exploiting brief gaps in the coordinated defense.
- Predator confusion effect: attackers have measurably lower strike success rates against dense, fast-moving schools than against lone individuals.