Flocking is a simulation that consists of boids in groups. The boids maneuver around to simulate real-life flocking behavior such as birds and fish. Boid is short for bird-oid, but they are just generic objects that interact with other boids to form flocks. Even after being seperated by obstacles, all boids will gradually conform back into groups. Each boid follows three behaviors: separation, alignment, and cohesion.
- Separation: A boid does not want to be too close to other boids.
- Alignment: A boid wants to move in the same direction as the others.
- Cohesion: A boid wants to stay close to the other boids.
- Python 3.6+
#clone the project
git clone https://github.com/chenterry85/Flocking-Simulation.git
#install dependencies
python3 -m pip install -U pygame==2.0.0.dev6 --user
#run program
python3 main.py
Press:
- "Left Click" β add new boid
- "Right Click" β add new obstacle
- "β" arrow key β speed up boid
- "β" arrow key β slow down boid
- "r" key β randomize boid position
- "c" key β clear canvas