Ball in a Square Hole — LLM Implementation Comparison 1024×1024 toroidal field · 200×200 square with 100×100 hole · ball Ø10 · both bodies mass 1 · perfectly elastic, no friction

Each file below is an independent attempt by a different LLM at the same brief: a ball bouncing inside a concave square on a wrapping 1024² plane, with total momentum and kinetic energy exactly conserved. This index summarises what each one does, what is broken or risky, and highlights the strongest entries. Source files live next to this index.html.

Best / reference Notable / ambitious Caveats Bugs / wrong physics

Round 0 — minimal brief (no rotation)

First wave of attempts, mostly short single-file scripts. Mixed quality.

0!_glm52max.html Best overall Conservation HUD Wrap-aware
Most polished. Impulse-based 1-D normal-velocity swap on the four inner edges, fixed 1/240 s sub-step accumulator, wrap-aware relative coordinates, full conservation diagnostics (Σp, |Σp|, ΣKE, COM drift), velocity vectors, trail, time-scale slider.
0!_claude_opus48t.html Clean velocity-swap model Tile render
Equal-mass velocity-swap on the inner X and Y walls with sub-stepping and 3×3 ghost-tile rendering. The swap is exact and conserves Σp and ΣKE on paper.
0_step37f.html Works, but specialised
Four AABB wall rects built from the frame minus the hole, with a 3×3 toroidal tile search. Positional correction is split by inverse mass.
0_qwen36ct.html Trail effect, fragile wrap test
Per-edge checkWall with wrap-aware range test, plus a fading ball trail. Visually nice.
0_laguna21.html No wrap, wrong contact
Inner walls as four normals; square reflects off hard field edges.
0_qwen36t diz.html No two-body coupling
Simplest implementation: a 1D bounce in the hole-relative frame, with a wrap.
0_step37f_bug_ball_escape.html Ball can escape (named for the bug)
Eight wall passes against 1×1 slabs at the inner and outer edges.

Round 1 — brief extended with optional rotation

Now the square should support free rotation about its centre, with the analytic moment of inertia for a frame with a square hole. A toggle locks rotation while leaving translation free.

0-GPT56luna.html Clean rigid body Wrap-aware Rotation
Impulse-based collision with analytic frame inertia, free-rotation toggle, fixed sub-step accumulator, and wrap-aware 9-copy rendering. Matches the quality of 01_hy3.html in fewer lines.
0-dots3.html Compact, with rotation
Compact implementation with adaptive sub-stepping, 9-copy tiling, and a rotation toggle. Initially contained two bugs: a sign error in the collision physics and a malformed layout that blocks checkbox.
01_hy3.html Notable — full rigid body Angular-momentum invariant
The only implementation that actually carries angular momentum: analytic moment of inertia for the frame with hole, impulse split between linear and rotational degrees of freedom, diagnostics for linear and angular Σ.
01_qwen38_27b_hermes.html Rotation toggle present
Compact, well-commented. The rotation checkbox toggles free rotation with moment of inertia.
01_qwen38_27b_i4.htm Largest of the round
A long single-file attempt with rotation support and an HTML/CSS UI. Useful as a baseline to compare line counts against.
01_ornith1.html Multiple balls
Variation that runs more than one ball inside the same hole — collision-against-other-balls logic is added on top of the wall collision.
01!_glm52m_grok45_rot.html Notable — extended HUD Tailwind UI
A more elaborate cousin of 0!_glm52max.html: same impulse core but with the rotation toggle added, a side panel, time-scale slider, and a full live readout (ball/square speed and components, Σp now/init, ΣKE now/init, COM-drift speed, FPS).
01!_claude48ot_c46_rot.html Notable — careful seam handling
A near-twin of 0!_co48t.html extended with rotation. Clean visual style and explicit tile-relative rendering.

Round 2 — synthesised "best of" + extra features

Later passes that combine ideas from earlier implementations and add presentation features.

02_hy3+synth.html Most complete Rotation HUD Tile render
Combines the rigid-body rotation of 01_hy3.html with the wrap-aware impulse core and the conservation diagnostics of the GLM 0/1 entries. Closest to a reference implementation in this set.
02_hy3+synth21.html Reference variant
Sibling of 02_hy3+synth.html with minor variations — useful to see what small refactors change about the simulation behaviour.
02_hy3+synth22.html Reference variant
Another sibling of 02_hy3+synth.html. Same engine, different cosmetic / UI choices.
02_qwen38_27b_ornith1_hermes.html Notable — adds sound Multiple synth modes
A late-stage attempt that adds an audio synthesiser: a different tone is generated for each bounce, with selectable mapping (mean of pre/post speeds, constant pitch, speed-proportional, or only-on-bounce).

Common issues across the set

If you only open three