What It Demonstrates

This simulation models collective animal behaviour using Craig Reynolds' Boids algorithm (1986). Each fish follows three simple local rules β€” separation, alignment, and cohesion β€” yet the global result is realistic, fluid schooling. When the predator shark approaches, fish switch to a flee response, generating spectacular split-and-regroup dynamics.

How to Use

Adjust Fish Count, Speed, and the three flocking-force radii. Toggle the predator on/off to compare schooling with and without threat. Try large cohesion radius for tight schools, or large alignment radius for highly synchronised groups.

Did You Know?

Fish schools confuse predators via the confusion effect β€” a predator targeting one fish loses it in the crowd. Boids-like models are also used in animation (e.g. the stampede in The Lion King) and autonomous drone swarm coordination.