oneshotlm
Compare all models on this prompt →

Bouncing balls in a heptagon · ling-2.6-flash

Output generated Cost / run $0.0002 Runtime 41.5s

Prompt for this run

Show 20 numbered balls (1 to 20) dropping from the center of a heptagon that spins 360 degrees every 5 seconds. The balls are affected by gravity and friction, collide with each other, and bounce realistically off the rotating walls; show each ball's spin via the rotation of its number. Implement all collision detection yourself.

⛨ sandboxed Open in new tab ↗

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

modelling-2.6-flash
vendorinclusionai
harnesspi-agent
generated2026-08-01

METRICS

runtime41.5s
tokens in12k
tokens out4.0k
cached1.6k
cost / run$0.0002
Transcript · 6 messages
user

Show 20 numbered balls (1 to 20) dropping from the center of a heptagon that spins 360 degrees every 5 seconds. The balls are affected by gravity and friction, collide with each other, and bounce realistically off the rotating walls; show each ball's spin via the rotation of its number. Implement all collision detection yourself.

assistant

I'll create a single HTML file with a physics-based simulation of 20 numbered balls dropping from a heptagon that spins continuously. The balls will collide with each other and the rotating walls, with realistic bouncing and spin rotation.

→ write /tmp/ws/index.html (9969 bytes)
toolResult

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

assistant

The file has been created at `/tmp/ws/index.html`. Let me verify it exists and is complete:

→ bash {"command":"ls -la /tmp/ws/index.html && head -5 /tmp/ws/index.html && echo \"...\" && tail -5 /tmp/ws/index.html"}
toolResult

-rw-r--r--. 1 node node 9969 Aug 1 17:33 /tmp/ws/index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> ... initBalls(); requestAnimationFrame(loop); </script> </body> </html>

assistant

The file is complete. Here's what the implementation does: ## Features 1. **Spinning Heptagon**: A 7-sided polygon rotates at 360° every 5 seconds (angular velocity = 2π/5 rad/s) 2. **20 Numbered Balls**: Each ball (numbered 1-20) starts from the center area and falls under gravity 3. **Physics Simulation**: - **Gravity**: Constant downward acceleration (700 px/s²) - **Friction**: Air resistance applied each frame (0.98 multiplier) - **Elastic Collisions**: Ball-to-ball collisions with proper momentum transfer - **Wall Bouncing**: Realistic reflections off the rotating heptagon walls with restitution - **Canvas Boundary**: Balls also bounce off the outer edges 4. **Ball Spin**: Each ball's number rotates based on its speed — faster movement = faster spin, creating a dynamic visual effect 5. **Custom Collision Detection**: All collision detection is implemented from scratch: - Line-segment vs circle collision for heptagon walls - Circle-circle collision for ball-to-ball interactions - Proper normal reflection and restitution calculations 6. **Visual Design**: Dark space-themed background with a subtle grid, translucent heptagon outline, and blue numbered balls The simulation runs entirely in a single self-contained HTML file with no external dependencies. Just open it in any modern browser to see the physics in action!