oneshotlm
Compare all models on this prompt →

Boids flocking · glm-4.6

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 Open in new tab ↗
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
The user wants a single-page web app with a flocking simulation. Let me break down the requirements:

1. Full-screen flocking simulation of boids
2. Use separation, alignment, and cohesion rules
3. Boids should be drawn as oriented triangles
4. Smooth steering
5. Boids should flee from the mouse cursor
6. Everything in one self-contained HTML file with inline CSS and JS
7. No external resources or network requests

I'll need to implement:
- Boid class with position, velocity, acceleration
- Vector2D math for calculations
- Separation (avoid crowding neighbors)
- Alignment (steer towards average heading of neighbors)
- Cohesion (steer towards average position of neighbors)
- Mouse fleeing behavior
- Smooth steering with force limits
- Triangle rendering that rotates based on velocity direction
- Canvas rendering for performance

Let me create this step by step in a single HTML file.
write /tmp/ws/index.html (14863 bytes)
toolResult

Successfully wrote 14863 bytes to /tmp/ws/index.html

assistant
thinking
I've created a complete flocking simulation in a single HTML file. The implementation includes:

1. **Vector2D class** - Handles all the math for position, velocity, and acceleration
2. **Boid class** - Implements the three main flocking behaviors:
   - Separation (avoid crowding neighbors)
   - Alignment (steer towards average heading)
   - Cohesion (steer towards average position)
   - Mouse fleeing behavior
3. **Full-screen canvas** with gradient background
4. **Triangle rendering** that rotates based on velocity direction
5. **Smooth steering** with force limits and acceleration
6. **Mouse interaction** - boids flee from cursor
7. **Click to add more boids**
8. **Performance optimizations** like edge wrapping and trail effects
9. **FPS counter and boid count display**

The simulation creates natural-looking flocking behavior with smooth movement and the boids actively avoid the mouse cursor while maintaining their flocking patterns. The triangles are properly oriented based on their movement direction, and there's a subtle glow effect for visual appeal.

Created a full-screen flocking simulation with boids that exhibit realistic flocking behavior. The boids are rendered as oriented triangles that steer smoothly using the three classic rules: separation, alignment, and cohesion. They actively flee from the mouse cursor when it gets near, creating an interactive experience. Click anywhere to add more boids to the simulation. The entire application is self-contained in a single HTML file with no external 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-4.6
vendorZ.ai · GLM
harnesspi-agent
generated2026-08-01

EVALUATION

4/5 working

Glowing triangular boids flock and flee smoothly from the cursor circle, with idle animation and clear separation/cohesion behavior.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion7.8%
on click15.1%
on drag16.9%
on wheel18.5%
on enter + space10.2%
on arrow keys11.8%
on w/a/s/d11.8%
frame spread20.4 / 255
console errors0
js errors none

METRICS

runtime120.7s
tokens in6.1k
tokens out3.4k
cached6.0k
cost / run$0.0074