Skip to content

Python implementation of the boid algo, with pygame visualization.

License

Notifications You must be signed in to change notification settings

FrancoisPgm/boids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

boids

Implementation of the boids algo, with a pygame visualization.

Example GIF

Instructions

Clone the repo, and install dependencies:

git clone https://github.com/FrancoisPgm/boids.git
cd boids
pip install -r requirements.txt

To run the simulation:

python3 main.py

You can quit the simulation by pressing the escape key.
You can reset the boids during the simulation by pressing the R key.
You can show sliders to control the boids parameters by pressing the S key, and hide the sliders by pressing it again.

Some options can be changed with several flags :

python main.py --help
usage: main.py [-h] [--n_boids N_BOIDS] [--fps FPS] [--show_fps] [--fullscreen]
               [--width WIDTH] [--height HEIGHT] [--bg_col BG_COL BG_COL BG_COL]
               [--boid_col BOID_COL BOID_COL BOID_COL] [--ang_col] [--speed SPEED]

optional arguments:
  -h, --help            show this help message and exit
  --n_boids N_BOIDS, -n N_BOIDS
                        Number of boids, default=150.
  --fps FPS             FPS, default=60.
  --show_fps            Show FPS.
  --fullscreen          Show in full screen.
  --width WIDTH         Window width, ignored if fullscreen, default=1200.
  --height HEIGHT       Window height, ignored if fullscreen, default=800.
  --bg_col BG_COL BG_COL BG_COL
                        Background color in RGB, default is balck.
  --boid_col BOID_COL BOID_COL BOID_COL
                        Color of boids in RGB, default is random.
  --ang_col             Change color of boids according to their angle, if set it
                        overrides boid_col.
  --speed SPEED, -s SPEED
                        Maximum speed, defult=15.

For example:

python main.py --show_fps --n_boids 200 --boid_col 195 195 95

Credits:

Pygame visualization code based on https://github.com/Nikorasu/PyNBoids (Copyright (c) 2021 Nikolaus Stromberg - [email protected])

Boids rules based on https://github.com/beneater/boids (Copyright 2020 Ben Eater)

About

Python implementation of the boid algo, with pygame visualization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages