Flocking Behaviour of Boids

Flocking behaviour of boids is an example of emergence, wherein a simple set of rules can be used to achieve complex behaviour.



Highlighter:

Behaviour toggles:







Rules

Separation: If two boids come close to each other, they try moving in different directions to avoid colliding. There is no form of communication between them. The light-gray circle denotes the region around the boid where this rule comes into play.

Alignment: A boid moves in the average direction of the boids around it. The medium-gray circle denotes the region whose boids are considered. The blue coloured line points towards the average direction

Cohesion: A boid moves towards the average position of the boids around it. The dark-gray circle denotes the region whose boids are considered.




Note:
  1. Radius of Separation region cannot be changed because it may lead to crashes
  2. Alignment is critical for flocking behaviour.
  3. However, if a single flock is formed, then turning off alignment will almost never have any effect.
  4. Turning off separation will cause the boids to clump together. Some of these clumps will cease net movement because they move around each other.
  5. Simulation may lag in low-end devices. Simulation may lag if too many boids are introduced.



Developed by ChanRT | Fork me at GitHub