oneshotlm
← Back to comparison

Boids flocking · glm-5.2

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 · 4 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
Let me create a flocking simulation with boids. I'll write it all into a single index.html file.
write /workspace/index.html (14423 bytes)
toolResult

Successfully wrote 14423 bytes to /workspace/index.html

assistant

Done. I created `/workspace/index.html` — a self-contained full-screen boids simulation. **What it does:** - Each boid steers using the three classic Reynolds rules — **separation**, **alignment**, and **cohesion** — combined into a single acceleration that's limited by a `maxForce`, giving smooth, gradual turns (no instant snapping). - Boids are drawn as **oriented triangles** pointing in their velocity direction, each tinted with a slightly different hue. - Moving the mouse exerts a **flee force** whose strength scales with proximity (stronger the closer a boid is), shown by a soft pink influence radius around the cursor. - The world wraps around the screen edges, and a faint trailing clear gives a nice motion smear. **Performance & engineering details:** - A **spatial hash grid** (rebuilt each frame) limits neighbor queries to nearby cells, so it scales fine up to ~400 boids. - Force vectors use a max-speed / max-force steering model (Reynolds-style "desired minus velocity, clamped"). - Touch input is supported too, so it works on mobile. **Interactive controls (top-right):** - Sliders for separation, alignment, cohesion, fear-of-mouse, and population. - A "Reset Flock" button reseeds positions/velocities. HUD (top-left) shows live boid count and FPS. Open `index.html` in any browser — no network, no dependencies.

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

modelglm-5.2
vendorZ.ai · GLM
harnesspi-agent
generated2026-07-07

METRICS

latency141.1s
tokens in5.1k
tokens out5.0k
cached2.4k
cost / run$0.0202