Boids

Boids (bird-oids) are artificial creatures that simulate the flocking behavior of natural birds. They were originally described by Craig W. Reynolds in a 1987 paper on simulating aggregate behavior of groups of individuals.

Each boid independently decides how to move according to the following set of rules:

  1. Move toward the center of mass of the other boids within some neighborhood
  2. Keep a small distance from other boids to avoid collisions
  3. Try to match the velocity of nearby boids

I've added the 'colors' flocking rule here, which incorporates chromatic distance, in addition to spacial, when each boids considers their neighbors. So in order to be considered a neighbor, a boid must be relatively close spacially and have a similar color. Basically boids will only flock with similarly colored boids if 'colors' is on.