# Boids Flocking — Reynolds Rules

Emergent flocking from three local rules: separation, alignment, cohesion

> Canonical page: https://elysiatools.com/en/visualizations/boids-flocking-reynolds

- **Category:** Math

## Overview

Interactive Boids flocking simulation — Craig Reynolds' 1986 model where lifelike group behavior emerges from only three local rules (no global leader): separation (steer to avoid crowding), alignment (match neighbour heading), cohesion (steer toward neighbour centroid). Distinct from existing agent-based cases (Langton ant = single-agent cellular automaton on a lattice; Schelling segregation = discrete-grid game theory) — this is continuous-space multi-agent swarm dynamics with emergent polarization, milling, splitting and re-merging. Neighbour lookup uses a uniform spatial-hash grid so each boid checks only its own cell + 8 neighbours, keeping the whole step O(n) and smooth up to 500 boids. Three independent sliders (0–3) control the separation/alignment/cohesion weights, plus population (10–500), vision radius, and max speed. 5 presets: classic, tight ball, loose swarm, milling, streaming. Click the canvas to drop a grey predator — boids within its threat radius flee directly away (polarization drops), then cohesion/alignment self-heal the flock once the predator leaves, mimicking real starling murmurations. Live metrics: polarization (|mean velocity direction|, 0=chaos to 1=uniform), mean speed, centroid, predator count, with a polarization bar. Optional overlays: centroid trail and per-boid vision-radius rings. Integration uses semi-implicit Euler with wrap-around (toroidal) boundaries and per-boid speed clamping. Verified by 53 model tests (vector math, spatial-hash cross-cell queries, force directions, wrap-around, emergent polarization rise, predator flight+recovery). Educational content covers the three Reynolds rules, emergence and self-organization, local perception and the spatial hash, predator escape and self-healing re-grouping, and applications (films like Batman Returns / LOTR, swarm robotics, UAV coordination, particle swarm optimization). Multi-language support (zh, en, es, fr, de, ru, pt).

## Related content

- [Zero-Order Reaction - Interactive Visualization](https://elysiatools.com/en/visualizations/zero-order-reaction): Interactive visualization of zero-order reaction kinetics and concentration changes over time
- [First-Order Reaction - Interactive Visualization](https://elysiatools.com/en/visualizations/first-order-reaction): Interactive visualization of first-order reaction kinetics and exponential concentration decay
- [Second-Order Reaction - Interactive Visualization](https://elysiatools.com/en/visualizations/second-order-reaction): Interactive visualization of second-order reaction kinetics and bimolecular collision dynamics
- [Arrhenius Equation](https://elysiatools.com/en/visualizations/arrhenius-equation): Interactive visualization of temperature effect on reaction rate - Explore activation energy, pre-exponential factor, and rate constant relationship
- [Reversible Reaction](https://elysiatools.com/en/visualizations/reversible-reaction): Interactive visualization of A ⇌ B reversible reaction kinetics - Explore forward and reverse reaction rates, equilibrium constant, and concentration changes over time
- [Consecutive Reaction](https://elysiatools.com/en/visualizations/consecutive-reaction): Interactive visualization of A → B → C consecutive reaction kinetics - Explore intermediate concentration peaks, rate-determining steps, and complete evolution of all species
- [Chain Reaction](https://elysiatools.com/en/visualizations/chain-reaction): Interactive visualization of free radical chain reaction polymerization - Explore initiation, propagation, termination steps, chain growth animation, and molecular weight distribution
- [Le Chatelier's Principle](https://elysiatools.com/en/visualizations/le-chateliers-principle): Interactive visualization of Le Chatelier's Principle - Explore how changes in concentration, pressure, and temperature affect chemical equilibrium with animated molecular dynamics
