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

Related simulators

Continue with similar topics in this category — or all 85 in Classical Mechanics.

View category →
NewSchool

Particle Life

Launch Simulator

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

NewSchool

Pendulum Collision

Launch Simulator

Two bobs: hit along normal, e elastic; θ¨ between hits vs 1D collisions.

School

Spring-Mass System

Launch Simulator

Simple harmonic motion with adjustable spring constant and damping.

FeaturedSchool

Projectile Motion

Launch Simulator

Launch projectiles with adjustable angle, velocity, and gravity. Trace parabolic paths with real-time graphs.

NewSchool

Center of Mass System

Launch Simulator

2–4 bodies or rod: R_cm, V_cm; explosion with ΣΔp = 0; |P| and |V_cm| graphs.

NewSchool

Conical Pendulum

Launch Simulator

Steady cone: ω(θ,L), T and mg vectors, T_rev vs simple-pendulum T₀.

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)

Separation, alignment, cohesion on a torus; cursor as predator cue.

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

About this model

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

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.