BOIDS.JS
A high-performance flocking library for the modern web. Simulate complex collective behavior with algebraic precision.
The Legacy of
Craig Reynolds
In 1986, Craig Reynolds revolutionized computer animation by introducing the world to "Boids", an artificial life program that simulated the flocking behavior of birds.
Instead of complex global control, Reynolds proved that group intelligence could emerge from three simple local rules: Separation, Alignment, and Cohesion.
BoidsJS pays homage to this groundbreaking discovery, bringing the same mathematical elegance to the modern web with optimizations for real-time interactivity and scalability.
Separation
Steer to avoid crowding local flockmates.
Alignment
Steer towards the average heading of flockmates.
Cohesion
Steer to move towards the average position of flockmates.
The Power of Seven
While Reynolds defined the rules, researchers at Princeton University discovered how birds actually apply them. By studying starling murmurations, they found that each bird tracks exactly their seven nearest neighbors.
This topological interaction, rather than a fixed radius, provides the most robust balance between individual effort and group cohesion, allowing flocks to maintain their structure regardless of density.
BoidsJS implements this "7-Nearest" optimization, providing a highly performant alternative to classic O(n²) spatial sensing.
Three Distinct
Movements
BoidsJS provides native support for multiple steering behaviors, allowing you to choose the right balance between performance, style, and fidelity.
Classic Reynolds
The original 1986 implementation using global sensing and O(n²) complexity for high-fidelity flocking behavior.
7-Nearest Optimized
A modern optimization that limits perception to the 7 closest neighbors, reducing computational load and better matching natural flocking behavior.
Dynamic Flow Fields
Boids follow an underlying noise map that evolves over time, creating organic, wind-like movement patterns.