Labs · Autonomous Agents
Flocking (Boids)
Craig Reynolds' boids: each bird follows three local rules and only sees neighbours within its perception radius.
- Separation: steer away from neighbours that are too close.
- Alignment: match the average heading of neighbours.
- Cohesion: steer toward the neighbours' centre.
No bird is in charge, and no rule describes "a flock", yet flocks emerge. This is emergence. A spatial grid keeps neighbour lookups fast enough for hundreds of boids.
Set cohesion to 0, then separation to 0, and see how each rule shapes the flock. Click to add boids.
Controls
- Boids
- Separation
- Alignment
- Cohesion
- Perception radius
- Max speed
- Max force
- Mouse
Evolved into Predators & Prey, Crowd Evacuation.