Boids vs Particle Swarm Optimization: Two Very Different Uses of "Swarm" Behaviour
Both simulations show many agents moving together, but Boids models realistic flocking for animation and biology while Particle Swarm Optimization repurposes swarm motion as a numerical search algorithm for finding minima.
🧪 Try both simulations
⚡ Quick answer
Boids simulates realistic flocking/schooling motion (birds, fish) using three local steering rules: separation, alignment and cohesion — its goal is a visually believable emergent group behaviour. Particle Swarm Optimization (PSO) borrows the "swarm" metaphor but repurposes it as an optimization algorithm: each particle is a candidate solution pulled toward its own best result and the swarm’s best result, converging on the minimum of a cost function.
📊 3D Boids — Flocking vs Particle Swarm Optimization — Swarm Intelligence
| 3D Boids — Flocking | Particle Swarm Optimization — Swarm Intelligence | |
|---|---|---|
| Purpose | Simulate believable group animal motion (animation, biology, games) | Solve numerical optimization problems (find the minimum of a function) |
| Origin | Created 1986 by Craig Reynolds for computer animation of flocks/herds/schools | Created 1995 by Kennedy & Eberhart, inspired by bird flocking but built as an optimizer |
| Steering rules | Separation, alignment, cohesion — each agent reacts only to nearby neighbours | Velocity update pulled toward personal-best position and global-best position, no neighbour-only rule |
| What each agent "is" | A simulated bird/fish with position and heading | A candidate solution (a point in the search space) with position and velocity |
| Success metric | None — pure visual emergent behaviour | Distance of the swarm’s best particle to the true global minimum of the cost landscape |
| Convergence | Never "converges" — flocks keep moving indefinitely | Designed to converge — particles cluster around the best-found minimum over iterations |
| Best for learning | Emergent behaviour from simple local rules ("swarm intelligence" in nature) | How simple bio-inspired rules can solve real optimization problems without gradients |
Boids and Particle Swarm Optimization both simulate crowds of simple agents that appear to move with collective intelligence — but they were built for opposite purposes. Craig Reynolds’ 1986 Boids algorithm exists purely to make flocking look right on screen: each of the 500 agents in this site’s 3D simulation only obeys three local rules — steer away from crowding neighbours (separation), match their average heading (alignment), and steer toward their average position (cohesion). There is no "goal"; the flock simply keeps moving in a visually convincing way forever.
Particle Swarm Optimization takes the same flocking inspiration and turns it into a search algorithm. Instead of birds in physical space, each "particle" is a candidate answer to an optimization problem, moving through an abstract cost landscape. It is pulled toward the best position it has personally found and the best position any particle in the swarm has found — so over enough iterations, the whole swarm converges on (hopefully) the global minimum. Watching this site’s PSO simulation try several test functions makes the contrast obvious: unlike Boids, PSO is explicitly trying to finish, not just look alive.
Want to explore more? Browse the full library of 1000+ interactive, browser-based simulations, or see other side-by-side comparisons.