Bouncing balls in a heptagon · claude-sonnet-5.5
Output generated Cost / run $0.0625 Runtime 38.8s
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.
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
METRICS
Transcript · 8 messages
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.
/tmp/job-Qs8zY4/index.html (4619 bytes){"action":"screenshot"}Successfully wrote to /tmp/job-Qs8zY4/index.html
Frame 1, +0ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"","images":"attached"}
thinking
I'm checking that the canvas scaling stays square and that the heptagon shape renders proportionally correctly.
{"action":"motion"}Frame 1, +0ms
[Browser image supplied to model]
Frame 2, +579ms
[Browser image supplied to model]
Frame 3, +1152ms
[Browser image supplied to model]
Frame 4, +1739ms
[Browser image supplied to model]
{"console":["warning: An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing."],"dom":"","images":"attached"}
I built `index.html` in `/tmp/job-Qs8zY4`. It shows 20 numbered balls dropping from the center of a heptagon that spins once every 5 seconds. The motion frames I captured show them falling, piling up in the lower corner and rolling along the walls as it turns. I haven't looked at the console beyond the sandbox iframe warning, and I didn't test other window sizes. What I saw in the frames: - **Drop:** the balls are released one at a time, 0.25 s apart. - **Walls:** they bounce off the moving walls and the heptagon carries the pile around with it. - **Collisions:** ball-to-ball and ball-to-wall collisions are my own code, with no physics library. - **Spin:** the numbers rotate on each ball, so you can see them spinning. I didn't measure whether the spin matches the rolling speed. Gravity, friction and bounciness are constants at the top of the script if you want to tune them.