oneshotlm
← Back to comparison

Boids flocking · deepseek-v4-flash

Create a full-screen flocking simulation of boids using separation, alignment, and cohesion, drawn as oriented triangles that steer smoothly and flee from the mouse cursor.

⛨ sandboxed
transcript · 6 messages
user

Create a full-screen flocking simulation of boids using separation, alignment, and cohesion, drawn as oriented triangles that steer smoothly and flee from the mouse cursor.

assistant
thinking
The user wants a full-screen boids flocking simulation in a single HTML file. Let me create a complete implementation with:

1. Full-screen canvas
2. Boids as oriented triangles
3. Separation, alignment, and cohesion steering behaviors
4. Smooth steering
5. Mouse flee behavior

Let me write a comprehensive implementation.
write /workspace/index.html (7967 bytes)
toolResult

Successfully wrote 7967 bytes to /workspace/index.html

assistant
thinking
Let me verify the file is correct and test it.
bash {"command":"wc -l /workspace/index.html && head -5 /workspace/index.html && echo \"---\" && grep -c 'script>' /workspace/index.html && grep
toolResult

299 /workspace/index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> --- 2 1

assistant
thinking
The file is 299 lines, has a script tag (opening), and the closing html tag. Let me verify it runs properly by opening it with a headless browser or checking structure.

The simulation is ready at **`/workspace/index.html`** — open it in a browser to see the flock in action. **What's implemented:** - **200 boids** rendered as oriented triangles (pointing in their direction of travel) - **Three flocking rules:** - **Separation** — each boid steers away from nearby neighbors within 28px - **Alignment** — each boid matches the average velocity of neighbors within 60px - **Cohesion** — each boid steers toward the average position of neighbors within 60px - **Mouse flee** — boids panic and scatter away when the cursor comes within 140px (with a subtle red influence zone drawn on screen) - **Smooth steering** — accelerations are capped (`MAX_FORCE = 0.2`) for natural, gradual turning - **Speed clamping** — velocities stay between a minimum liveliness threshold and `MAX_SPEED = 4` - **Wrap-around** — boids seamlessly wrap across all four edges - **Trail effect** — a semi-transparent background fill creates motion blur - **Glow** — cyan shadow on the triangles gives them a subtle neon look - **Fully self-contained** — no external resources, CDNs, or network requests

TAKE IT TO CODE

A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.

RUN

modeldeepseek-v4-flash
vendorDeepSeek
harnesspi-agent
generated2026-07-07

METRICS

latency95.0s
tokens in5.1k
tokens out3.1k
cached5.2k
cost / run$0.0011