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.
Simulation Controls