You are a trashcan with a delicious stench. All of the flies want to be near you.
This demo is an implementation of the famous Boids algorithm, as described by Conrad Parker. One of the great things about Boids is that you get a fun, emergent herding behavior from three simple rules.
There are three main forces acting on the flies (and one bonus):
- Cohesion - the tendency of each fly to move towards the average of the group
- Separation - the tendency of each fly to move away from any fly close to it
- Alignment - the tendency of each fly to adjust it’s velocity to the average of the group.
This code also implements a 4th dynamic:
- A goal - each fly will also tend to move towards the goal: you! the trash can.