oneshotlm
Compare all models on this prompt →

Boids flocking · kimi-k2-thinking

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 · 8 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
We need to create a full-screen flocking simulation using boids with separation, alignment, and cohesion behaviors. The boids should be drawn as oriented triangles that steer smoothly and flee from the mouse cursor. All code needs to be contained in a single HTML file.

Key requirements:
- Full-screen (canvas that covers entire viewport)
- Boids with separation, alignment, and cohesion behaviors
- Drawn as oriented triangles that point in their direction of movement
- Smooth steering
- Flee from mouse cursor
- Single self-contained file (index.html)
- Inline CSS and JS, no external resources

I need to:
1. Create an HTML file with proper structure
2. Include a canvas that fills the entire screen
3. Implement boid class with position, velocity, acceleration
4. Implement separation (avoid crowding neighbors)
5. Implement alignment (steer towards average heading of neighbors)
6. Implement cohesion (steer towards average position of neighbors)
7. Add flee behavior from mouse cursor
8. Draw each boid as an oriented triangle
9. Ensure smooth steering by limiting acceleration and velocity
10. Add mouse tracking
11. Use requestAnimationFrame for smooth animation

Let me start by reading any existing files to see if there's already something in the workspace.

I'll create a full-screen flocking simulation with boids that flee from the mouse cursor. All code will be in a single HTML file.

bash {"command":"ls -la"}
toolResult

total 0 drwxr-sr-x. 2 node node 6 Aug 1 19:46 . drwxrwsrwx. 3 root node 16 Aug 1 19:46 ..

assistant
thinking
The workspace is empty. I'll create a complete flocking simulation in a single `index.html` file. Let me design the structure:

1. HTML structure with full-screen canvas
2. CSS for full-screen layout
3. JavaScript implementation:
   - Vector class for 2D math operations
   - Boid class with flocking behaviors (separation, alignment, cohesion)
   - Flee behavior from mouse cursor
   - Drawing boids as oriented triangles
   - Main animation loop

Let me write this out:
write index.html (7736 bytes)
toolResult

Successfully wrote 7736 bytes to index.html

assistant
thinking
The file has been created successfully. Let me verify it's there by reading it to confirm the content was written correctly.
read {"path":"index.html","limit":50}
toolResult

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flocking Boids Simulation</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { overflow: hidden; background-color: #0a0a0a; cursor: none; } canvas { display: block; width: 100vw; height: 100vh; background-color: #111; } </style> </head> <body> <canvas id="canvas"></canvas> <script> // Vector class for 2D operations class Vector { constructor(x = 0, y = 0) { this.x = x; this.y = y; } add(v) { this.x += v.x; this.y += v.y; return this; } sub(v) { this.x -= v.x; this.y -= v.y; return this; } mult(n) { [283 more lines in file. Use offset=51 to continue.]

assistant
thinking
The file was created successfully. The flocking simulation is complete with all the requested features:

1. Full-screen canvas that responds to window resizing
2. Three classic Reynolds boid behaviors (separation, alignment, cohesion)
3. Boids drawn as oriented triangles
4. Smooth steering with velocity and acceleration vectors
5. Flee behavior from mouse cursor
6. All in a single self-contained HTML file

The implementation includes:
- Vector class for 2D math operations
- Boid class with proper behavioral separation, alignment, and cohesion
- Mouse tracking for flee behavior
- Tails effect for visual appeal
- Proper boundaries handling
- Oriented triangle rendering based on velocity direction

The file is ready to be used. When opened in a browser, users will see a flocking simulation with 100 boids that smoothly follow each other, avoid crowding, and flee from the mouse cursor.

Done! I've created a complete full-screen flocking simulation in a single `index.html` file. The simulation features: - **Three core behaviors:** Separation, alignment, and cohesion - **Oriented triangles:** Each boid is drawn as a triangle pointing in its direction of movement - **Smooth steering:** Velocity and acceleration vectors for natural movement - **Flee behavior:** Boids actively avoid the mouse cursor within a 120px radius - **100 boids** with cyan gradient coloring - **Trails effect** from semi-transparent fill per frame - **Wrapping edges** to keep boids on screen - **Responsive canvas** that adapts to window resize The file is self-contained with: - Inline CSS (full-screen styles) - Inline JavaScript (Vector and Boid classes, animation loop) - No external dependencies or network requests Open `index.html` in a web browser to see the flocking simulation.

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

modelkimi-k2-thinking
vendorMoonshot · Kimi
harnesspi-agent
generated2026-08-01

EVALUATION

4/5 working

Boids flock into flowing schools with oriented triangle shapes, continuously animating; keyboard/pointer inputs show no distinct additional reaction beyond ongoing flocking.

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 motion9.0%
on click10.9%
on drag10.0%
on wheel10.3%
on enter + space10.9%
on arrow keys10.5%
on w/a/s/d10.4%
frame spread12.5 / 255
console errors0
js errors none

METRICS

runtime21.5s
tokens in11k
tokens out3.1k
cached7.9k
cost / run$0.0110