Watch 900 boids create complex flocking patterns from three simple rules
This simulation recreates the flocking behavior of birds (murmurations) using an algorithm called "Boids," developed by Craig Reynolds in 1986. Despite the complexity of the patterns that emerge, each individual boid follows just three simple rules:
To efficiently handle 900+ boids, this simulation uses a quadtree data structure. Instead of checking every boid against every other boid (which would require hundreds of thousands of calculations per frame), the quadtree spatially organizes the boids into regions.
Each boid only checks for neighbors within its perception radius by querying the quadtree, dramatically reducing the computational load. You can toggle the quadtree visualization to see how the space is recursively subdivided.
This simulation embodies a key principle in complex systems: sophisticated collective behavior can emerge from simple individual rules. No boid has knowledge of the overall flock pattern, yet together they create the mesmerizing swirling formations we see in nature.
This same principle applies across nature—from ant colonies to neural networks to slime molds. Intelligence and coordination don't always require central control; they can arise from local interactions.