rahmanfaiz / final-year-project

0 stars 1 forks source link

Final Year Project: Boid Algorithm

The Background

The Rules

In the flock, each boid agent must obey three main building blocks that mentioned above:

  1. Cohesion Boid is attracted to each other and they attempt to stay close relative to each other.
  2. Separation Boid will maintain a certain distance that separate each other so they didn't collide with each other
  3. Alignment Boid would to try align their velocity (speed and direction) with nearby boid

The Math

Position of each boid $x_i$ is updated by velocity $v_i$ that has been computed every frame/timescale iteratively. The $\Delta v_i$ is calculated by adding all of the building blocks that is,

with i is the boid we're working with; j is another boid; W is weight that determines the amplitudes of these interaction; S is interaction range around each agent; n is number of each boid that evaluated in the range. Adding them up, we get the equation below:

$$ \Delta v_i = Wc \cdot \Delta v{i-c} + Ws \cdot \Delta v{i-s} + Wa \cdot \Delta v{i-a}$$