For this week's assignment, I was very drawn to the idea of creating flocking behavior. After taking a look at the coding challenge tutorial, I decided to allow the user to be able to manipulate the different variables that would affect the field of vision of each bird within the flock, as well as the speed. This way, the flocking behavior can be adjusted in a variety of ways. 

The three main aspects of simulating flocking, as described by Craig Reynolds. 

The 'detection zone' for each bird within the flock. In my assignment, I would like to have the user be able to adjust the scale of the neighborhood. 

Because I opted to use ellipses instead of triangles, I named my boid object class 'humanoid' instead, since the ellipses reminded me of heads within a crowd. Each object contains vectorized velocity and acceleration units, as well as limits for speed and force.

To satisfy the first requirement of 'flocking', I needed to achieve alignment. This means that one humanoid must steer itself towards the average direction of the other humanoids in its immediate vicinity

Cohesion is similar to alignment, but also different in that rather than attaining the average velocity, a humanoid should be able to match the direction of the other humanoids in the neighborhood. In other words, I needed to get the average position of the flock

Now, to set the acceleration of the humanoids in the flock to both alignment and cohesion parameters, we just add them together.

Sliders set to respective speed, force, and field of vision variables.

While I managed to achieve cohesion and alignment for the flock, I didn't get a chance to implement separation, which is the third element that should be present in flocking. Looking forward, I would like to be able to create this behavior as well, to avoid the flock members sticking together into one inseparable unit. 
Back to Top