oneshotlm
← Back to comparison

Boids flocking · glm-4.7-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 flocking simulation (boids algorithm) in a single HTML file. This should include:

1. Full-screen canvas
2. Boids drawn as oriented triangles
3. Three main behaviors: separation, alignment, and cohesion
4. Smooth steering
5. Boids should flee from the mouse cursor

Let me create a comprehensive single-file solution with:
- Canvas setup
- Boid class with position, velocity, acceleration
- Separation, alignment, cohesion behaviors
- Mouse avoidance behavior
- Smooth steering using velocity and acceleration limits
- Triangle rendering oriented in the direction of velocity

I'll write this all in one index.html file.
write index.html (15038 bytes)
toolResult

Successfully wrote 15038 bytes to index.html

assistant
thinking
I've created a complete flocking simulation in a single HTML file. Let me verify it works by checking the file exists and maybe running a quick test to see if it renders properly.
bash {"command":"ls -lh index.html"}
toolResult

-rw-r--r-- 1 node node 15K Jul 7 00:12 index.html

assistant
thinking
The file is created successfully. It's 15KB and contains:
1. Full-screen canvas setup
2. Boid class with position, velocity, acceleration
3. Three flocking behaviors: separation, alignment, cohesion
4. Mouse avoidance behavior
5. Oriented triangle rendering
6. Controls for adjusting parameters
7. Visual effects like gradients and glow

The simulation should work right away when opened in a browser. Let me verify it works by checking if we can open it.

I've created a complete flocking simulation in `index.html`. The application features: **Core Features:** - **200 boids** rendered as oriented triangles that point in their direction of movement - **Three flocking behaviors:** - **Separation** - Boids avoid crowding neighbors - **Alignment** - Boids steer toward the average heading of nearby flock members - **Cohesion** - Boids move toward the center of mass of nearby flock members - **Mouse avoidance** - Boids flee from your cursor (with adjustable fear distance) - **Smooth steering** - Uses velocity and acceleration with proper limits **Visual Effects:** - Colorful gradients (cyan to blue) that shift based on velocity direction - Glowing triangle shapes - Motion blur trail effect - Pulsing mouse cursor indicator **Interactive Controls:** - Separation strength - Alignment strength - Cohesion strength - Mouse fear/flee distance - Maximum speed Just open `index.html` in any modern browser to see the simulation running. Move your mouse around the screen and watch the flock scatter and regroup!

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-4.7-flash
vendorZ.ai · GLM
harnesspi-agent
generated2026-07-07

METRICS

latency69.8s
tokens in172
tokens out3.8k
cached11k
cost / run$0.0016