Flocking with Obstacles
Boids flocking with added obstacle avoidance. When an agent detects an obstacle ahead, it steers away proportional to how close and how centered the obstacle is in its path. Click to place new obstacles.
About this lab
Obstacle avoidance extends the basic boids model with an additional steering force. For each obstacle, an agent calculates whether the obstacle lies ahead in its path: if the distance to the obstacle is less than a lookahead distance and the lateral displacement is less than the obstacle radius, the agent steers laterally away, with strength proportional to 1/d².
This produces naturalistic detour behavior: the flock splits around obstacles and reforms on the far side. The challenge is tuning the relative weights so that obstacle avoidance overrides cohesion when necessary, while not fragmenting the flock when obstacles are distant. At high avoidance strength, agents become highly responsive; at low strength, some agents may clip obstacle boundaries.
The same principles apply in robot motion planning, autonomous vehicle navigation, and computer game AI. Reynolds himself extended his work on steering behaviors to include path following, pursuit, evasion, and formation keeping.