A demonstration of emergent behavior in the form of flocking "bird-like objects" or boids.
See the Getting Started section below if you would like to try the simulation out for yourself.
There are essentially three rules that determine a boids behavior towards another boid:
- Alignment
- Adjust your heading according to the average heading of your neighbors.
- Cohesion
- Move toward the center of mass of your neighbors.
- Separation
- To avoid crowding, move away from any boid you get too close to.
A boid is only able to track boids within a certain distance. They do not know of boids far away.
Additionally, they will avoid predators. An evade response is evoked when a predator comes within range of a boid, this is a stronger effect than the other behaviors. The predators themselves do not flock.
By combining all these factors, boids will demonstrate flocking behavior of all sizes and shapes. They can even avoid predators when they do not see one, as they respond to their neighbor's movements.
If you would like to learn more I encourage you to read the Wikipedia entry. (Be careful - it's a rabbit hole!)
Left-click to add new boids
Right-click to add predators
- Knowledge of basic CLI usage
- Python3 (download page on python.org)
- Tkinter:
- When installing Python check "tcl/tk and IDLE" under optional features
git clone https://github.com/alecthedev/tk-boids.git
cd tk-boids./run.sh-
Currently there is no UI for tweaking the strength of the adjustments boids make. Any playing around must be done in your editor.
-
In the boid.py file there is a dictionary in the Boid class called
self.adjustmentsfeel free to tweak these values to your liking.
("randomness" makes slight adjustments for more organic boid movement)
Thanks for checking out my project, I hope you at least enjoyed the gifs if nothing else :)




