oneshotlm
Compare all models on this prompt →

Bouncing balls in a heptagon · glm-5.3

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 ↗
transcript · 4 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
thinking
Write a physics sim: heptagon rotating, balls inside, ball-wall collision with rotating wall (tangential velocity from wall rotation), ball-ball collisions, spin rendering via rotation angle. Single file.

Key math: heptagon center C, radius R, angular speed ω = 2π/5. Wall segments: vertices Vi = C + R*(cos(θi+φ), sin(θi+φ)). For ball collision with segment: find closest point on segment, if dist < r, push out, reflect velocity. Wall velocity at contact point = ω × r_vec = ω*(-(y-Cy), (x-Cx)). Relative velocity vrel = v - vwall; reflect vrel about normal; v = vwall + reflected with restitution.

Ball-ball: elastic collision with restitution and positional correction.

Spin: give angular velocity from tangential impulse; simple: when bouncing, spin = tangential relative velocity / r; render number rotated by spin angle.

Gravity ~ moderate scale. Canvas ~700px. R ~ 300, ball radius 14.

Write code.
write index.html (5691 bytes)
toolResult

Successfully wrote 5691 bytes to index.html

assistant

Done — `index.html` contains the full simulation: - **Spinning heptagon**: 7-sided polygon rotating 360° every 5 s (ω = 2π/5), drawn on canvas with green edges and vertex markers. - **20 balls** (numbered 1–20, each a distinct hue) drop from the center with gravity and air friction. - **Ball–wall collisions**: closest-point-on-segment detection against each rotating edge; the wall's tangential surface velocity (from rotation) is included in the reflection, plus tangential friction that imparts spin. - **Ball–ball collisions**: pairwise circle overlap with positional correction and impulse-based elastic response (restitution 0.9), with spin exchange from tangential friction. - **Spin visualization**: each ball's number rotates by its accumulated angular velocity, updated from bounce impulses and damped over time. - Physics runs in fixed substeps for stability; no external resources at all.

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-5.3
vendorZ.ai · GLM
harnesspi-agent
generated2026-08-27

EVALUATION

4/5 working

Numbered balls bounce and settle inside a spinning heptagon with gravity, collisions, and rotation; inputs don't add new interactivity.

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.3%
on click6.9%
on drag7.0%
on wheel7.1%
on enter + space7.2%
on arrow keys7.3%
on w/a/s/d7.0%
frame spread15.9 / 255
console errors0
js errors none

METRICS

runtime30.8s
tokens in5.4k
tokens out2.5k
cached2.2k
cost / run$0.0160