Skip to content

chenterry85/Flocking-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flocking Simulation

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.

Requirements

  • Python 3.6+

Installation

#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

Controls

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