Interactive demo

Boids Flocking Simulation

This code is based on the boids idea by Craig Reynolds. For more information visit https://www.red3d.com/cwr/boids/. The flocking behaviour of the boids tries to simulate the natural way fish or birds would move in groups. This simulation only needs three core rules: alignment, cohesion and separation.

Your browser does not support the HTML5 canvas tag.

Rule weights

Display

The three rules of flocking

Alignment

Steer towards the average heading of local flockmates.

Cohesion

Steer to move toward the average position of local flockmates.

Separation

Steer to avoid crowding local flockmates.