Artificial Life Flocking Simulation (Boids) new

Flocking Simulation (Boids)

Emergent collective behavior from three simple rules

Controls
Behavior
Effects

The Boids Algorithm

Developed by Craig Reynolds in 1986, Boids simulates the flocking behavior of birds using three simple steering rules applied to each individual agent.

The Three Rules:

  • Separation: Steer to avoid crowding nearby flockmates. Each boid maintains minimum distance from neighbors to prevent collisions.
  • Alignment: Steer towards the average heading of nearby flockmates. Boids match their velocity with their neighbors.
  • Cohesion: Steer towards the average position of nearby flockmates. Boids move toward the center of mass of their local group.

Emergent Behavior: Despite these simple rules operating locally, complex global patterns emerge: coordinated flocking, splitting and merging groups, obstacle avoidance, and predator evasion.

Parameters:

  • Perception Radius: How far each boid can “see” its neighbors
  • Max Speed / Max Force: Limits on velocity and steering acceleration
  • Rule Weights: Relative influence of separation, alignment, and cohesion
© 2013 - 2026 Cylian Size:  T S M L W Theme:  Dark Light [Detected] [Forced] 0.62.0 (f7ef9462) 🤖 Claude
About

Generation Prompt

Page: Flocking Simulation (Boids)
Slogan: "Emergent collective behavior from three simple rules"

Structure:
- Widget before:title -> h1 + p.slogan centered
- Main -> Canvas in .card.full.ratio-16-9 (HD via devicePixelRatio)
- Widget after:algorithm -> Explanation of the 3 rules
- Widget modal:claude -> Documentation

Boids Implementation:
- Each boid is a triangle pointing in movement direction
- Three steering behaviors:
  1. Separation: avoid crowding neighbors (short range)
  2. Alignment: match velocity with neighbors (medium range)
  3. Cohesion: move toward center of mass (medium range)

Parameters:
- Flock size: number of boids (default 100)
- Perception radius: neighbor detection range (default 50px)
- Max speed: velocity limit (default 4)
- Max force: steering force limit (default 0.1)
- Separation weight: importance of separation (default 1.5)
- Alignment weight: importance of alignment (default 1.0)
- Cohesion weight: importance of cohesion (default 1.0)

Optional features:
- Predator mode: click to add predator, boids flee
- Obstacles: static zones boids avoid
- Wrap edges: boids reappear on opposite side

Rendering:
- Triangles oriented in velocity direction
- Color based on velocity or group
- Trail effect (optional)

Animation loop:
1. For each boid, find neighbors within perception
2. Calculate separation, alignment, cohesion forces
3. Apply forces with weights, limit to max force
4. Update velocity, limit to max speed
5. Update position, wrap edges
6. Draw as oriented triangle