Welcome! This is my implementation of the boids algorithm developed by Craig Reynolds. By having each boid independently follow 3 simple rules, complex group behavior emerges that simulates the flocking behavior of birds. The rules are as follows:
I also added obstacle avoidance, where the boids will steer away from and avoid the cursor.
This project was made using p5.js and basic CSS, HTML, and JS. To challenge myself during development, I implemented a quad tree to handle neighbor detection which you can see with debug mode. Enjoy!
Click to spawn more boids
D - toggles debug mode, outlining the nodes of the quadtree and highlighting one boid to show which nodes are included in the neighbor search
S - toggles obstacle avoidance to control whether boids avoid the cursor
R - resets simulation