More than just being intersting to watch, the more intersting part of modeling flocking/schooling behavior is that it is an emergent behaviour arising from simple rules that are followed by individuals and does not involve any central coordination.
Basic models of flocking behaviour are controlled by three simple rules:
Separation - Avoid crowding neighbours (short range repulsion)
Alignment - Steer towards average heading of neighbours
Cohesion - Steer towards average position of neighbours (long range attraction)
In this project I wanted to add additional and unique behaviors for the predators and the prey. The prey get an avoid behavior to avoid the predators, and the predators get a chase behavior, to chase the prey.
The idea behind this project was to implement Boids in Javascript and also add predators to chase the schooling fish.
The idea came from seeing an arial view of sharks swimming though a school of fish. See the images below.