oneshotlm
Compare all models on this prompt →

Snake · gpt-oss-120b

Output generated Cost / run $0.0010 Runtime 82.2s

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-oss-120b
vendorOpenAI
harnesspi 0.87.1 · browser iteration
generated2026-10-07

METRICS

runtime82.2s
tokens in19k
tokens out2.6k
cached11k
cost / run$0.0010
Transcript · 12 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
We need to build index.html with canvas game. Then open in browser, test movement, pause/resume, restart. We'll need to use browser tool; after writing file, open via browser? Use a function? There's a 'browser' tool type. We'll need to call browser with action maybe "load" or something. The description says "Run index.html, inspect DOM/console, interact, and see screenshots or motion frames". Not sure exact API. Possibly action: "load" with url? Let's try.

First create index.html file with code. Ensure controls: Start button, Pause/Resume toggle, Restart button. Display score and controls text.

Implement game loop using setInterval with speed (e.g., 150ms). Direction handling: store pendingDirection, only update if not opposite.

Board size 20x20, cell size maybe 20px -> canvas 400x400.

Implement snake as array of coordinates (x,y). Starting length 3, moving right.

Food placed randomly in empty cells, if board full -> win.

Game states: 'stopped', 'running', 'paused', 'over', 'win'.

Implement Start: if stopped go to running. Pause toggles pause.

Restart: reset variables and set state stopped? maybe show ready.

Implement.

After writing file, use browser tool to load page and maybe capture screenshot to verify behavior? Not needed but should run.

Let's write index.html.
→ write index.html (6086 bytes)
toolResult

Successfully wrote to index.html

assistant
assistant
thinking
Now we need to run the application in browser, test initial output and console, make few turns, pause/resume, restart, verify. Use browser tool. Need to see what actions available. Perhaps action "navigate" or "load". Let's try calling browser with action: "load" and url maybe "index.html".
→ browser {"action":"load","url":"index.html"}
toolResult

Validation failed for tool "browser": - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant Received arguments: { "action": "load", "url": "index.html" }

assistant
thinking
We need correct actions list. We don't have documentation. Might be "open", "click", "type", "screenshot". Let's search docs.
→ bash {"command":"ls -R"}
toolResult

.: index.html

assistant
thinking
Maybe there is a browser tool usage pattern in other tasks. Let's guess common actions: "navigate" with url, "click", "key" etc. Let's try "navigate".
→ browser {"action":"navigate","url":"index.html"}
toolResult

Validation failed for tool "browser": - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant - action: must be equal to constant Received arguments: { "action": "navigate", "url": "index.html" }

assistant
thinking
We need to inspect documentation for browser tool. Maybe defined elsewhere. Search repo for 'browser' usage.</thinking to=functions.bash<|channel|>commentary code<|message|>{"command":"grep -R \"type browser\" -n .. || true"}