oneshotlm
Compare all models on this prompt →

Snake · qwen3.5-9b

Output saved · Stopped by an API error Cost / run $0.0036 Runtime 199.3s

A model request failed and its retries ran out. The output is the HTML saved before that.

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

modelqwen3.5-9b
vendorQwen
harnesspi 0.87.1 · browser iteration
generated2026-10-07

METRICS

runtime199.3s
tokens in53k
tokens out4.3k
cached31k
cost / run$0.0036
Transcript · 23 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
I need to build a Snake game with the following requirements:

1. 20x20 cell board on canvas
2. Arrow keys to control direction
3. Snake advances one cell at a time
4. Ignore direction that would reverse into own neck
5. Ignore rapid inputs before next movement step
6. Place one food item in unoccupied cell
7. Eating food grows snake by one segment, increases score, spawns new food
8. Solid board boundaries - hitting wall or body ends game
9. Moving into tail cell that vacates on same non-growing step is allowed
10. Start, Pause/Resume, Restart buttons
11. Restart resets snake length, direction, score, food, game state
12. Filling board shows win state
13. Display controls and score
14. Prevent arrow keys from scrolling page

Let me write this as a single HTML file with inline CSS and JS.

Key game logic:
- Snake is an array of segments with {x, y} positions
- Direction is one of: UP, DOWN, LEFT, RIGHT
- Game loop with fixed speed
- Food placement in random unoccupied cell
- Collision detection with walls and self
- Win condition when board is full

Let me code this:
→ write index.html (13845 bytes)
toolResult

Successfully wrote to index.html

assistant
thinking
Now let me run the application in the browser to verify the functionality.
→ bash {"command":"cd /tmp/job-W8Orx1 && python3 -m http.server 8080 &"}
toolResult

/bin/bash: line 1: python3: command not found

assistant
thinking
Let me try with python instead.
→ bash {"command":"cd /tmp/job-W8Orx1 && python -m SimpleHTTPServer 8080 &"}
toolResult

/bin/bash: line 1: python: command not found

assistant
thinking
Let me check what's available.
→ bash {"command":"which node || which php || which python3 || which python"}
toolResult

/usr/local/bin/node

assistant
thinking
Node is available. Let me start a simple HTTP server using node.
→ bash {"command":"cd /tmp/job-W8Orx1 && node -e \"const http = require('http'); const fs = require('fs'); const server = http.createServer((req, r
toolResult

node:events:487 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE: address already in use :::8080 at Server.setupListenHandle [as _listen2] (node:net:2009:16) at listenInCluster (node:net:2066:12) at Server.listen (node:net:2171:7) at [eval]:1:222 at runScriptInThisContext (node:internal/vm:219:10) at node:internal/process/execution:451:12 at [eval]-wrapper:6:24 at runScriptInContext (node:internal/process/execution:449:60) at evalFunction (node:internal/process/execution:283:30) at evalTypeScript (node:internal/process/execution:295:3) Emitted 'error' event on Server instance at: at emitErrorNT (node:net:2045:8) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 8080 } Node.js v24.18.0

assistant
thinking
Port 8080 is already in use. Let me try a different port.
→ bash {"command":"cd /tmp/job-W8Orx1 && node -e \"const http = require('http'); const fs = require('fs'); const server = http.createServer((req, r
toolResult

Server running on port 3000

assistant
thinking
Good, the server is running. Now let me open the browser and test the game.
→ bash {"command":"curl -s http://localhost:3000 | head -50"}
toolResult

/bin/bash: line 1: curl: command not found

assistant
thinking
Let me use the browser tool to inspect the page.
→ bash {"command":"echo \"Opening browser to test...\""}
toolResult

Opening browser to test...

assistant
thinking
Let me use the browser tool to inspect the page.
→ bash {"command":"echo \"Opening browser to test...\""}
toolResult

Opening browser to test...

assistant
assistant
assistant