oneshotlm
← Back to comparison

Boids flocking · qwen3.6-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 boids flocking simulation in a single HTML file with:
- Full-screen canvas
- Boids as oriented triangles
- Three rules: separation, alignment, cohesion
- Boids steer smoothly
- Boids flee from mouse cursor
- All CSS in <style>, all JS in <script>, no external resources

Let me build a complete, polished implementation.
write /workspace/index.html (11608 bytes)
toolResult

Successfully wrote 11608 bytes to /workspace/index.html

assistant
thinking
The file is written. Let me verify it exists and is complete.
bash {"command":"wc -l /workspace/index.html && head -3 /workspace/index.html && echo \"---\" && tail -3 /workspace/index.html"}
toolResult

415 /workspace/index.html <!DOCTYPE html> <html lang="en"> <head> --- </script> </body> </html>

assistant
thinking
The file is written. Let me provide a summary of what was built.

Done — `/workspace/index.html` contains the full self-contained boids flocking simulation with: **Three classic flocking rules:** - **Separation** — boids steer away from neighbors within 28px (inverse-distance weighted, so close peers repel harder) - **Alignment** — boids steer toward the average heading of neighbors within 80px visual range - **Cohesion** — boids steer toward the center of mass of nearby neighbors **Plus:** - **Mouse flee** — a visible repulsion radius (140px) where boids flee from the cursor with distance-weighted force - **Edge avoidance** — soft steering away from viewport boundaries - **Speed clamping** — min/max speed enforced each frame - **Smooth steering** — acceleration integrated with decay (0.92 factor), clamped to 0.6 max accel **Visual features:** - Oriented triangle boids drawn as polygons with bright cores and colored glow - Hue shifts based on heading, saturation/brightness based on speed - Semi-transparent background redraw creates motion trails - Mouse repulsion zone shown as a faint radial gradient **Performance:** - Spatial hash grid (`CELL = 80px`) for O(n) neighbor lookups instead of O(n²) - 350 boids at full res with devicePixelRatio scaling - Delta-time capped loop step for stability No external resources — runs entirely sandboxed.

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

modelqwen3.6-flash
vendorQwen
harnesspi-agent
generated2026-07-07

METRICS

latency35.0s
tokens in13k
tokens out4.6k
cached0
cost / run$0.0076