Flocking Algorithm(Boids).

Project Inspiration and Overview.

I have been wanting to look at the flocking algorithm for a while. Now that I have extra time I decided to look deeper into the flocking algorithm. This project involves implementing the flocking algorithm using Unity. It is also part of a larger project I am working on in game creation using the Unity engine.

General Algorithm.

The general algorithm involves utilizing 3 aspects to create the emergent behaviour which are:

  • Cohesion: This involves how close together an agent would be to its surrounding neighbours. The higher the cohesion, the more tightly packed the flock will be.
  • Alignment: This guides the agent as to where the direction of the overall flock is headed towards.
  • Separation: This guides the agent as to what distance should it be from its surrounding neighbours. It is the direct opposite of cohesion.

Demonstration.

Demonstration of the boids algorithm in action can be shown below:



I implemented sliders which can adjust the number of agents in the flock. Cohesion, alignment and separation slider interfaces were also implemented.

Resources.

Source code to this project can be found here.
Other resources in relation to the algorithm can be found in the following links: