oneshotlm
← Back to comparison

Boids flocking · mimo-v2.5

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 me to create a full-screen flocking simulation with boids. Let me plan out what this needs:

1. **Boids algorithm** - Craig Reynolds' flocking algorithm with three core rules:
   - **Separation**: Steer away from nearby boids to avoid crowding
   - **Alignment**: Steer toward average heading of nearby boids
   - **Cohesion**: Steer toward average position of nearby boids

2. **Visual representation** - Oriented triangles that point in their direction of movement

3. **Smooth steering** - Interpolate velocity changes rather than instant direction changes

4. **Mouse flee behavior** - Boids should flee from the mouse cursor

5. **Full-screen** - Canvas fills the entire window

Let me build this as a single HTML file with inline CSS and JS.
write /workspace/index.html (7445 bytes)
toolResult

Successfully wrote 7445 bytes to /workspace/index.html

assistant
thinking
The file has been written. Let me verify it's there.
bash {"command":"ls -la /workspace/index.html"}
toolResult

-rw-r--r-- 1 node node 7518 Jul 7 00:11 /workspace/index.html

assistant
thinking
The file is created. Let me provide a summary to the user.

Done — **`/workspace/index.html`** is ready. Open it in a browser to see: ### What's happening | Feature | Detail | |---|---| | **320 boids** | Rendered as oriented triangles whose tip points in their travel direction | | **Separation** | Each boid steers away from neighbours within a small radius to avoid crowding | | **Alignment** | Boids match the average velocity of nearby flockmates | | **Cohesion** | Boids steer toward the centre of mass of the local flock | | **Smooth steering** | Forces are capped (`MAX_FORCE = 0.12`) and blended via velocity limiting, so turns are gradual | | **Mouse flee** | Move the cursor near boids — they peel away smoothly within a 180 px radius | | **Click attract** | Hold mouse down — boids reverse behaviour and are pulled toward the cursor | | **Edge softening** | Boids gently steer back from screen edges instead of hard-wrapping | | **Motion trail** | A low-alpha dark fill each frame leaves colour trails behind fast-moving boids | | **Colour** | Hue shifts from cyan → blue based on each boid's speed | No external resources — everything is self-contained in the single HTML file.

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

modelmimo-v2.5
vendorXiaomi · MiMo
harnesspi-agent
generated2026-07-07

METRICS

latency31.2s
tokens in2.9k
tokens out3.0k
cached7.6k
cost / run$0.0013