This project implements the Boids algorithm using the p5.js library. It simulates the flocking behavior of birds (or boids).
The Boids algorithm, developed by Craig Reynolds, simulates flocking behavior based on three simple rules that individual boids follow:
- Separation: Steer to avoid crowding local flockmates.
- Alignment: Steer towards the average heading of local flockmates.
- Cohesion: Steer to move towards the average position (center of mass) of local flockmates.
This simulation implements these rules to create emergent flocking patterns. Each boid has a limited vision radius and reacts only to boids within that radius.
Here are some ideas for enhancing the simulation:
- Wall Avoidance: Implement smoother wall avoidance behavior instead of wrapping around the edges. Boids could turn gradually when approaching boundaries.
- Leader Boids: Introduce leader boids that influence the flock's direction, potentially with random turns to increase dynamism. Leaders could be identified based on their position relative to the flock's center or average direction.
- Obstacle Avoidance: Add static or dynamic obstacles within the environment that the boids need to navigate around.
- Predator/Target: Introduce a predator boid that chases the flock or a target boid that the flock follows.
- Performance Optimization: For a very large number of boids, optimize the neighbor-finding process (e.g., using spatial partitioning techniques like quadtrees).
