oneshotlm
Compare all models on this prompt →

2048 · gpt-oss-120b

Build a playable 2048 game with arrow-key tile sliding and merging, smooth animations, a score, and win and lose states.

⛨ sandboxed Open in new tab ↗
transcript · 4 messages
user

Build a playable 2048 game with arrow-key tile sliding and merging, smooth animations, a score, and win and lose states.

assistant
thinking
We need to output a single index.html file containing the 2048 game. Must be self-contained: CSS in style, JS in script. No external resources.

We need to produce the file. We may just directly write the file.

We need to end with index.html present. So we will use the write tool with the content.

We must ensure the game works: implement a simple 2048 using HTML, CSS, JS. Use arrow keys, slide and merge, animations, score, win when reaching 2048 tile, lose when no moves.

Implementing full game within one file is okay.

We'll write HTML skeleton, <style> for grid layout, tiles, animation using CSS transitions. JS will manage board array, rendering, handling key events.

Simplify: using a 4x4 grid of divs, each tile is a div with class .tile and data attributes for value; using CSS transitions for transform, maybe animate adding new tile.

Implement functions:

- init(): board = 4x4 zero matrix; add two random tiles (2 or 4).
- addRandomTile(): find empty cells; choose random; set 2 (90%) or 4 (10%); create tile element with appropriate class.
- render(): update DOM for all tiles: for each cell, if value > 0, ensure a tile div exists at that position with class .tile and data-value; set text; set style left/top based on cell index, using CSS grid? Simpler: use position:absolute within container, set transform: translate(x,y). Or use CSS grid with grid-template and place items: we can create tile elements appended to container; assign .tile at grid position using CSS variable grid-row/column.

Better: container with position:relative, each tile absolute with top/left based on row*cellSize.

We'll implement smooth sliding using CSS transition on transform.

When moving: we compute new board after slide in direction, track moves and merges. For each movement we need to animate each tile to its new position. Simplify: after each move we update board and then call render which will set transform positions; CSS transition will animate.

Need to track merging: combine two identical adjacent tiles; the result tile gets value doubled; increase score.

Game over detection: after move if no empty cells and no adjacent equal tiles.

Win detection: tile value 2048 appears.

Score display.

Implement win overlay and game over overlay.

Okay.

We'll construct HTML:

<div id="game">
  <div id="score">Score: 0</div>
  <div id="grid"></div>
  <div id="message" class="overlay hidden"></div>
</div>

CSS: #grid size 500px, background, grid lines; .tile style: position absolute, width/height 115px (with margin), border-radius, background based on value (different colors), font, display flex center.

Animation: transition: transform 0.2s ease, background 0.2s.

JS: variables board, score, gameOver, won.

Functions: init, addTile, updateTile, move(direction) returns bool moved.

Key handling: document.addEventListener('keydown', ... arrow keys).

After each move, if moved, addRandomTile, render, check win/lose.

Implement overlay: show message "You win!" with button "Continue", similarly "Game Over".

Simplify: overlay with button reload.

Now we need to write file content.

We'll produce a fairly concise script.

We'll use a 4x4 grid with cell size 120px with 5px gap.

Let's craft code.

Proceed to write file.
write index.html (7467 bytes)
toolResult

Successfully wrote 7467 bytes to index.html

assistant

The playable 2048 game has been created in a single self‑contained file **index.html**. It includes all necessary HTML, CSS, and JavaScript, provides arrow‑key controls, smooth tile animations, scoring, and win/lose overlays. You can open this file in a browser to play.

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-agent
generated2026-07-22

EVALUATION

3/5 working

2048 grid responds to arrow keys with tile merging and score updates, but no visible win/lose UI shown.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion0.0%
on click0.0%
on drag0.0%
on wheel0.0%
on enter + space0.0%
on arrow keys8.7%
on w/a/s/d0.0%
frame spread24.4 / 255
console errors0
js errors none

METRICS

runtime75.1s
tokens in5.9k
tokens out3.5k
cached0
cost / run$0.0009