PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Classical Mechanics

Other simulators in this category — or see all 85.

View category →
NewSchool

Particle Life

Six types, pairwise matrix forces on a torus — clusters, worms, foam presets.

Launch Simulator
NewUniversity / research

Poincaré Section (Double Pendulum)

(θ₁, ω₁) when sin θ₂ crosses 0 with ω₂>0; RK4, chaotic return map.

Launch Simulator
NewSchool

Catenary Cable

Uniform chain between level anchors: y ∝ cosh(x/a); sag, arc length, tension directions.

Launch Simulator
NewSchool

Magnus Effect (Ball)

Same v₀ and θ with vs without spin: toy a = (kωv_y, −g − kωv_x); range comparison.

Launch Simulator
NewSchool

Fluid Surface (Accel / Spin)

Linear tank: tan α = a/g; rotating bucket: paraboloid sketch vs rpm.

Launch Simulator
NewUniversity / research

Water Hammer (1D)

Linearized P,V waves; valve closes; Joukowsky ΔP ≈ ρaV hint.

Launch Simulator
PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Classical Mechanics/Boids (Flocking)

Boids (Flocking)

The Boids simulator models the emergent collective behavior of animal groups, such as bird flocks or fish schools, using a simple agent-based system. Each agent, or 'boid,' follows three core behavioral rules based solely on local information from its neighbors within a defined perception radius. The rule of Separation steers a boid to avoid crowding local flockmates, creating a short-range repulsive force. Alignment compels a boid to steer towards the average heading of its local neighbors, promoting directional order. Cohesion guides a boid to move towards the average position of its local neighbors, acting as a long-range attractive force that maintains group integrity. Mathematically, these rules generate steering acceleration vectors which are summed, weighted by user-adjustable parameters, and integrated over time to update each boid's velocity and position, applying principles of kinematics. The simulation occurs on a toroidal space (a doughnut shape), meaning boids that exit one edge reappear on the opposite side, eliminating boundary effects. The user's cursor acts as a predator, introducing an external repulsive cue that disrupts the flock. This model is a classic example of emergence, where complex global order arises from simple local interactions without a central leader. Students learn about multi-agent systems, numerical integration, the trade-offs in rule-based modeling, and how decentralized control in biological systems can be described using concepts from computational physics and applied mathematics.

Who it's for: Undergraduate students in computational physics, biology, or computer science studying complex systems, emergence, and agent-based modeling.

Key terms

  • Emergence
  • Agent-Based Model
  • Steering Behaviors
  • Toroidal Topology
  • Local Interaction Rules
  • Collective Motion
  • Numerical Integration
  • Complex Systems

Flock

2.4
1.1
0.85
62 px

Lightweight O(N²) demo for modest N; toroidal world removes walls. Tweak weights to see mills, bands, or chaos.

Measured values

Boids96

How it works

Emergent order from three local rules — a go-to for collective motion without coding full fluid or field models.

Frequently asked questions

Is this a realistic model of actual bird flocking?
While it captures the core principles of decentralized coordination seen in nature, it is a significant simplification. Real animals have more sophisticated senses, reaction delays, and may weigh rules differently based on context (e.g., predator presence). This model demonstrates the minimal set of rules needed to generate flock-like behavior, making it a foundational rather than a fully accurate biological model.
Why is the simulation space a torus?
A toroidal (wrap-around) topology eliminates edge effects, allowing the study of flock dynamics in a boundless environment. This is a common simplification in simulations to maintain a constant population density and focus on the intrinsic interactions between agents, rather than artifacts from boundary collisions.
How does the 'predator' (cursor) interaction work?
The cursor introduces a fourth rule: avoidance. Boids within a certain range of the cursor perceive it as a threat and experience a strong repulsive steering force away from it. This demonstrates how external perturbations can disrupt emergent order, causing the flock to scatter and then potentially re-form, mimicking real-world predator-prey interactions.
What physics concepts are involved in updating a boid's motion?
The core concept is Newtonian kinematics. The summed steering vectors from the three rules produce an acceleration. This acceleration changes the boid's velocity over a small time step (Euler integration), and the updated velocity changes its position. It's a direct application of the equations of motion, albeit with velocities often clamped to a maximum speed to model energy expenditure or physical limits.