Skip to content

superchthonic/boids-p5js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boids Simulation

This project implements the Boids algorithm using the p5.js library. It simulates the flocking behavior of birds (or boids).

Boids Algorithm

The Boids algorithm, developed by Craig Reynolds, simulates flocking behavior based on three simple rules that individual boids follow:

  1. Separation: Steer to avoid crowding local flockmates.
  2. Alignment: Steer towards the average heading of local flockmates.
  3. 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.

Simulation Demo

Boids Simulation

Potential Improvements

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).

About

Boids Algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published