oneshotlm
Compare all models on this prompt →

Snake · gpt-5.6-terra

Output generated Cost / run $0.0719 Runtime 88.0s

Prompt for this run

Build a playable Snake game on a canvas with a 20 by 20 cell board. Use HTML, CSS, and JavaScript as needed. Write it to `index.html` in the current working directory using your file tools. Inline your own CSS and JavaScript. Do not use external assets, CDNs, or network requests. No third-party libraries are provided. Required behavior: - Use arrow keys to turn a snake that advances one cell at a time. Ignore a direction that would immediately reverse into its own neck, including rapid inputs before the next movement step. - Place one food item in an unoccupied cell. Eating it grows the snake by one segment, increases the score, and spawns new food in another unoccupied cell. - Use solid board boundaries: hitting a wall or the snake's body ends the game. Moving into a tail cell that vacates on that same non-growing step is allowed. - Provide Start, Pause/Resume, and Restart. Restart resets snake length, direction, score, food, and game state. Filling the board shows a win state instead of trying to place impossible food. - Display the controls and score. Prevent arrow keys from scrolling the page. Verify: Start the game and make a few turns to check grid-aligned movement and direction response. Pause and resume, then use Restart and check that snake length and score return to their initial values and food occupies a free cell.

⛨ 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

modelgpt-5.6-terra
vendorOpenAI
harnesspi 0.87.1 · browser iteration
generated2026-10-14

METRICS

runtime88.0s
tokens in185k
tokens out5.0k
cached165k
cost / run$0.0719
Transcript · 33 messages
system

user

Build a playable Snake game on a canvas with a 20 by 20 cell board. Use HTML, CSS, and JavaScript as needed. Write it to `index.html` in the current working directory using your file tools. Inline your own CSS and JavaScript. Do not use external assets, CDNs, or network requests. No third-party libraries are provided. Required behavior: - Use arrow keys to turn a snake that advances one cell at a time. Ignore a direction that would immediately reverse into its own neck, including rapid inputs before the next movement step. - Place one food item in an unoccupied cell. Eating it grows the snake by one segment, increases the score, and spawns new food in another unoccupied cell. - Use solid board boundaries: hitting a wall or the snake's body ends the game. Moving into a tail cell that vacates on that same non-growing step is allowed. - Provide Start, Pause/Resume, and Restart. Restart resets snake length, direction, score, food, and game state. Filling the board shows a win state instead of trying to place impossible food. - Display the controls and score. Prevent arrow keys from scrolling the page. Verify: Start the game and make a few turns to check grid-aligned movement and direction response. Pause and resume, then use Restart and check that snake length and score return to their initial values and food occupies a free cell.

assistant
thinking
**Considering build inspection**

I need to focus on building something, but it seems like I also need to inspect whether there are any files available—or maybe there are no files to inspect? That’s a bit unclear. I’ll have to clarify what needs to be done regarding the build. It feels important not to miss anything crucial that could affect the process. Alright, let’s figure this out together!
→ bash {"command":"ls -la && find . -maxdepth 1 -type f -print","timeout":10}
toolResult

total 12 drwx------ 3 node node 4096 Oct 14 08:01 . drwxrwxrwt 6 root root 4096 Oct 14 08:01 .. drwxr-xr-x 3 node node 4096 Oct 14 08:01 .home

assistant
thinking
→ write index.html (9282 bytes)
toolResult

Successfully wrote to index.html

assistant
thinking
→ browser {"action":"reload","x":0,"y":0,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nREADY","images":"attached"}

assistant
thinking
**Testing visibility**

I’m considering an interesting situation where a snake could be invisible due to an overlay, which makes it hard to see. But there were three green spots at the center that are somewhat obscured. I need to test out the start keyboard by clicking on “start” at approximately the coordinates 410,741 to take a screenshot. Let’s see how this goes to clarify the visibility issues with the overlay!
→ browser {"action":"click","x":407,"y":739,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nRUNNING","images":"attached"}

assistant
thinking
**Investigating screenshot issues**

I’m checking the DOM state, and it says it's running, but the overlay is visually ready. This likely means the screenshot is from a previous update. The browser's behavior seems odd; maybe it’s capturing a screenshot too quickly? I wonder if I could set up an interval for better timing. Also, the DOM overlay should definitely be hidden. I’ll need to inspect the screenshot to see if it’s stale or not.
→ browser {"action":"screenshot","x":0,"y":0,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nGAME OVER\nPRESS NEW GAME OR RESTART\nNEW GAME\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nGAME OVER","images":"attached"}

assistant
thinking
**Testing restart coordinates**

I'm thinking about the process of testing restart coordinates. It seems like I need to click restart first, then start, and finally follow a sequence with turn arrows. But I'm not sure about the timing since it might be uncontrollable due to interactions. I wonder how that will affect the overall outcome. I'll have to keep experimenting to figure it all out and refine the sequence. Let's see how it goes!
→ browser {"action":"click","x":810,"y":740,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nREADY","images":"attached"}

assistant
thinking
**Assessing the bug**

I need to assess a bug in the rapid planned queue. Limiting to 3 might help the sequence direction of the queue work better, but I think the exact game direction response is okay. We should consider making the overlay not too dark so it doesn’t obscure the snake. Also, the button to pause seems to have a disabled style that isn’t obvious. I’ll probably need to test clicking to start and then checking for immediate key responses.
→ browser {"action":"click","x":404,"y":740,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nRUNNING","images":"attached"}

assistant
thinking
→ browser {"action":"key","x":0,"y":0,"toX":0,"toY":0,"text":"ARROWUP","delta":0}
toolResult

keyboard.press: Unknown key: "ARROWUP"

assistant
thinking
→ browser {"action":"key","x":0,"y":0,"toX":0,"toY":0,"text":"ArrowUp","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nGAME OVER\nPRESS NEW GAME OR RESTART\nNEW GAME\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nGAME OVER","images":"attached"}

assistant
thinking
→ browser {"action":"click","x":400,"y":740,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nRUNNING","images":"attached"}

assistant
→ browser {"action":"click","x":615,"y":740,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nGAME OVER\nPRESS NEW GAME OR RESTART\nNEW GAME\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nGAME OVER","images":"attached"}

assistant
thinking
**Adjusting game speed**

I'm looking into the game speed adjustments. It seems that changing the speed to 220 or 280 might give some latency, but I might want to aim for 190 or 200 to improve response time. Slower speeds, like 180, could make the game more enjoyable without lag. I'll focus on ensuring the game is playable while accounting for browser tool latency. Ultimately, I think setting the speed to 160 will help the user have a smoother experience.**Testing viewport timings**

I’m noticing that the viewport snapshot time shows up as 0, but calls actually take about 2 seconds. To clarify, 20 times 125 equals 2.5 seconds, while 180 gives about 3.6 seconds. I think I need to include some response arrows in between actions. Since the user should have a reasonable experience, I’ll set the speed to 180. It might also be helpful to test a pause feature to further enhance the experience.
→ edit {"path":"index.html","edits":[{"oldText":"const SIZE = 20, CELL = 30, SPEED = 125;","newText":"const SIZE = 20, CELL = 30, SPEED = 180;"}]}
toolResult

Successfully replaced 1 block(s) in index.html.

assistant
thinking
→ browser {"action":"reload","x":0,"y":0,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nREADY","images":"attached"}

assistant
thinking
**Testing console functionality**

I need to mention only the sandbox warning for the console. I’m thinking about testing the pause and resume feature after starting an interaction, likely waiting around 3.6 seconds. It seems like I can only use sequential calls instead of parallel ones. Should I start with a click before the key? I believe tool calls might time at 0, but a screenshot could take about a second. Let’s go for starting, then using the key.
→ browser {"action":"click","x":405,"y":740,"toX":0,"toY":0,"text":"","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nREADY\nPRESS START TO BEGIN\nSTART\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nRUNNING","images":"attached"}

assistant
→ browser {"action":"key","x":0,"y":0,"toX":0,"toY":0,"text":"ArrowUp","delta":0}
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":"20 × 20 GRID RUNNER\nSNAKE\nSCORE\n000\nGAME OVER\nPRESS NEW GAME OR RESTART\nNEW GAME\nPAUSE\nRESTART\nSTEER WITH ↑ ↓ ← →\nDON'T HIT THE WALL OR YOURSELF.\nGAME OVER","images":"attached"}

assistant
thinking

Implemented the self-contained Snake game in [index.html](./index.html). Checked: - Initial render, 20×20 canvas grid, controls, score, and food display. - Start action changes game state and starts movement. - Restart resets state to `READY`, score to `000`, snake to its initial three segments, and generates food on a free cell. - Console showed no application errors (only the browser sandbox warning). The browser tool’s interaction latency let the snake reach the wall before reliable pause/turn checks could complete, so interactive turn sequencing and pause/resume were not fully browser-verified. The implementation includes queued direction handling, reverse-direction prevention, pause/resume, collision rules, food growth, and win handling.