Skip to main content

Module flock

Module flock 

Source
Expand description

Full boid/flocking simulation with obstacle avoidance, leader following, and predator flee.

This module implements Craig Reynolds’ Boids rules extended with:

  • Weighted steering behaviors (alignment, cohesion, separation)
  • Obstacle avoidance (sphere obstacles)
  • Leader following (follow a target point with arrival behavior)
  • Predator avoidance (flee from predator positions)
  • Speed limits and steering force clamping
  • Wall containment (keep boids within a bounding box)
  • Wander behavior (noise-driven random steering when idle)

Structs§

Boid
State for a single boid in the flock.
Flock
The complete flock — owns and ticks all boids each frame.
FlockConfig
Weights and limits for the boid steering behaviors.
FlockNeighbor
A neighboring boid for computing steering forces.
Obstacle
A spherical obstacle to avoid.

Functions§

compute_steering
Compute all steering forces for a single boid and return the total.
flock_force
Compute a steering force for one boid given its neighbors. Simplified version using just the three classic forces.