Game dev
Saved & recent

Flocking

Related terms: boids, separation, alignment, cohesion, crowds

The movement of a flock, a school of fish or a crowd, produced by three rules that each member follows using only its nearby neighbors. There is no leader and no plan.

Separation: do not crowd your neighbors. Alignment: head the same way they do. Cohesion: drift toward their center. The simulated members are called boids. A spatial grid keeps the neighbor search fast.

Further reading
Craig Reynolds: Flocks, Herds, and Schools: A Distributed Behavioral Model
separation alignment cohesion
Each fish responds to nearby fish. Separation steers away from close neighbors, alignment follows their average heading, and cohesion aims toward their average position.

View in the full Game dev collection