Daniel Litvak

Engineer & Developer

/ Back to portfoliop5.jsInteractive simulationSpatial indexingBoids

Flocking Birds

This is a combination of my two favourite projects, flocking boids and the quadtree. Interact with the canvas, and explore how the spatial indexing of a quadtree data can be used to speed up such simulations.

Description

  • Each boid samples neighbours within a 25px radius and applies cohesion, alignment, and separation forces.
  • A quadtree accelerates spatial queries so the flock stays performant even with 500 agents.
  • Edge repulsion keeps the flock near the center while mouse input temporarily attracts nearby boids.

Controls

Space toggles the quadtree debug overlay.

F toggles an FPS graph to track performance.

Click + Hold Mess with the birds.