Flock Simulation

P5 Javascript


An implementation of Craig Reynold's Boids to simulate the appearance of flocking birds or fish.

Each individual boid follows three rules which it uses to steer itself: avoidance, alignment, and coherence. Each boid also has a set position, velocity, direction, and 'area of influence'.

For avoidance, each boid checks the boids in its area of influence and steers away from their direct location. For alignement, the boids velocity is set to the average velocity of each boid in this area of influence. For coherence, each boids direction is steered towards the average direction of each boid in its area of influence.