oneshotlm
Compare all models on this prompt →

Double pendulum · claude-sonnet-5.5

Output generated Cost / run $0.0783 Runtime 34.9s

Prompt for this run

Simulate a chaotic double pendulum on a canvas using the correct equations of motion, drawing the arms and a colorful fading trail of the tip.

⛨ 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

modelclaude-sonnet-5.5
vendorAnthropic · Claude
harnesspi 0.87.1 · browser iteration
generated2026-10-05

METRICS

runtime34.9s
tokens in30k
tokens out4.4k
cached17k
cost / run$0.0783
Transcript · 13 messages
system

user

Simulate a chaotic double pendulum on a canvas using the correct equations of motion, drawing the arms and a colorful fading trail of the tip.

assistant
→ write /tmp/job-7q8dLT/index.html (2894 bytes)
→ browser {"action":"screenshot"}
toolResult

Successfully wrote to /tmp/job-7q8dLT/index.html

toolResult

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":"Restart (random)Pause\nTrail ","images":"attached"}

assistant
thinking
I realize the arms drawn each frame are leaving smeared ghosts on the persistent trail canvas since they're not separated from it. I need to restructure this with a separate offscreen canvas just for the fading trail, drawing the arms fresh on the main canvas every frame instead.

Arms are being painted into the persistent trail layer, so they would smear. I'll move the trail to an offscreen canvas.

→ bash {"command":"cd /tmp/job-7q8dLT && python3 - <<'E'\ns=open('index.html').read()\ns=s.replace(\"let W,H;function rs(){W=cv.width=innerWidth;H=
→ browser {"action":"reload"}
toolResult

/bin/bash: line 1: python3: command not found Command exited with code 127

toolResult

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":"Restart (random)Pause\nTrail ","images":"attached"}

assistant
thinking
It seems my edit didn't actually apply, and the pivot at 600,400 looks right but the screenshot shows no trail — I need to redo this using the edit tool directly instead.

Python isn't installed, so that patch didn't apply. I'll make the edits with the edit tool instead.

→ edit {"path":"/tmp/job-7q8dLT/index.html","edits":[{"oldText":"let W,H;function rs(){W=cv.width=innerWidth;H=cv.height=innerHeight;ctx.fillStyle=
→ browser {"action":"reload"}
→ browser {"action":"screenshot"}
toolResult

Successfully replaced 6 block(s) in /tmp/job-7q8dLT/index.html.

toolResult

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":"Restart (random)Pause\nTrail ","images":"attached"}

toolResult

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":"Restart (random)Pause\nTrail ","images":"attached"}

assistant
thinking
The pivot is at (600,400), a small dot, and the simulation seems slow in these screenshots, likely due to throttled frames early on. The trail is short but visible, so this looks good enough.

The double pendulum simulation is in `/tmp/job-7q8dLT/index.html`. The trail only showed as a short orange streak in my last screenshot, so I haven't seen a full colorful trail. The screenshots were taken moments after loading, and I didn't run a longer capture. I also didn't test the restart, pause or trail slider. - **Physics:** it uses the standard Lagrangian equations of motion for two point masses on rigid rods, with gravity 9.81 and both masses and lengths set to 1. They are integrated with RK4 at steps of 2 ms or less, so the motion stays accurate through the chaotic swings. - **Drawing:** the arms and bobs are white, with the pivot at the canvas center. The tip's trail is drawn on a separate layer so the arms don't smear into it. The trail changes color continuously and fades out over time. - **Controls:** a "Restart (random)" button starts from random angles, "Pause" freezes and resumes, and a "Trail" slider sets how fast the trail fades. The browser console showed only a sandbox iframe warning, with no errors from the page.