# Steering behaviours Agents that seek, flee, wander, arrive and flock ```{raw} html ▶ Run in browser ``` **Tags:** `ai` `steering` `boids` `numpy` Forty autonomous agents steer with the classic Reynolds behaviours, all vectorised in numpy. Number keys 1-4 switch every agent between seek, flee, wander and arrive; B switches to a boids flock built from separation, alignment and cohesion. The mouse is the target, and the highlighted agent draws its per-behaviour steering forces as coloured debug lines. ## What it demonstrates - Steering as "desired velocity minus current velocity", clamped to a force budget, integrated per frame in on_update. - Whole-population numpy updates: one (N, 2) array each for position and velocity, no per-agent Python loop. - Boids from three pairwise components (separation / alignment / cohesion) computed with a single (N, N) distance matrix. - Immediate-mode debug drawing: force vectors on one highlighted agent, with a legend naming each component. Controls: Mouse - Move the target 1/2/3/4 - Seek / Flee / Wander / Arrive B - Boids flock ESC - Quit Run: uv run python examples/features/ai/steering.py Headless self-check: uv run python examples/features/ai/steering.py --test ## Source ```{literalinclude} ../../examples/features/ai/steering.py :language: python :linenos: ```