oneshotlm
Compare all models on this prompt →

Snake · gpt-oss-20b

No runnable output Cost / run $0.0000 Runtime 7.5s

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.

⚠ no runnable output

This one-shot run produced no runnable artifact.

Provider finish_reason: error

The transcript below shows what the model did — read it to see why the one shot fell short.

TAKE IT TO CODE

This run produced no artifact — reuse the prompt with a different model or your own pi-agent run.

RUN

modelgpt-oss-20b
vendorOpenAI
harnesspi 0.87.1 · browser iteration
generated2026-10-07

METRICS

runtime7.5s
tokens in1.7k
tokens out573
cached832
cost / run$0.0000
Transcript · 3 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
Need to create index.html with canvas. Behavior: grid 20x20 cells. Need to handle drawing, snake body, movement timer. Provide start/pause/resume/restart. Score displayed. Food random. Prevent reverse direction.

Also need to support Stop/Restart. We'll create UI: Start button, Pause/Resume button, Restart button, score, instructions.

Must not allow arrow keys to scroll page: add event.preventDefault for keydown.

Game loop: set interval 200ms or variable speed.

We need to manage start: stops? When paused, should pause timer.

Implementation: global state: snake array of positions {x,y}. direction: current direction delta {dx,dy}. nextDirection: used to capture key events but avoid reversing.

food: {x,y}. score: number.

Functions:

draw(): clear canvas, draw cells as squares.

Place food: iterate random until unoccupied; if board full => win condition.

Game logic: on each tick, compute newHead = { x: head.x + dx, y: head.y + dy }.

Check wall: if newHead.x <0 or >=20 etc -> endGame.

Check self collision: need to check body excluding tail when moving without eating? "Moving into a tail cell that vacates on that same non-growing step is allowed." So we should check collision against body excluding tail if not growing (i.e., when not eating). Implementation: For normal step, tail will be removed; if newHead matches any body segment except tail, it's collision. If eating, tail not removed, so newHead vs all body segments counts.

We need to store tail removal: If not eating, pop tail from snake before adding new head? Usually, add new head, then if not eating, remove tail; but for collision check we need to consider tail not present if not eating.

Simplify: compute nextSnake = [newHead, ...snake]; If eating, remove tail after adding; else remove last after adding. For collision we consider if newHead collides with any segment except (if not eating) the last segment that will be removed; So check if newHead exists in body excluding last element if not eating. So implement method.

When food eaten: increase score, don't remove tail, spawn new food.

Start: set initial snake length 3 maybe? length? Let's set 3 segments.

Direction: initial maybe right (1,0). Starting grid: center.

Controls: Buttons. Provide event listeners.

Restart: clear interval, reset state, start new.

Start button: if game is over or paused? We'll set started flag, etc. On start, call resetGame(); startTimer(); show UI.

We'll also show score in a span.

Also ensure no arrow keys cause default scrolling: document.addEventListener('keydown