oneshotlm
Compare all models on this prompt →

2048 · gpt-5-mini

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
**Planning 2048 game implementation**

I need to create a single index.html file in the working directory and use a write tool to implement the 2048 game. This involves keyboard input for arrow keys, and potentially touch support. I'll write HTML with CSS and JS for smooth animations, score display, and win/lose detection without any external resources. The layout will be a 4x4 grid with tile objects. I’ll ensure animations are smooth, using CSS transitions and proper positioning for merging tiles and spawning new ones after moves.**Implementing game logic and structure**

I’m focusing on reliable transitionend events to implement game logic for sliding tiles. I need to iterate through each row and column to compress tiles in a 4x4 grid. Each tile will have an id and value, along with a merged flag. I’ll utilize incrementing ids and keep the tile DOM keyed by id for animations. Winning occurs when a tile reaches 2048, prompting an overlay, while losing happens if no moves are left. Additionally, I’ll handle controls and scoring, keeping code concise while crafting CSS for a visually appealing grid.**Developing the game class and mechanics**

I'm setting up the transition for transform effects over 150ms for movement and scaling during merges. I need to create a Game class that includes methods like init, setup, spawnTile, move(direction), canMove, and getAvailableCells. The movement algorithm will traverse cells to correctly combine tiles using vector mapping based on direction. I’ll implement a generic move function using iterations and helper functions to determine tile positions. For merging, I’ll ensure animations update properties and manage the DOM elements effectively. Overall, it follows the standard 2048 algorithm with a 2D array representation for the grid.**Finalizing transitions and scoring**

I need to increment the score and manage multiple transitions at once. To simplify things, I’ll set up a Promise that resolves after the animation duration plus a small buffer. I’m considering animation durations of 150ms for move and 100ms for merges. Using requestAnimationFrame will help ensure the layout updates correctly. After moving tiles, I’ll spawn a new tile and show an overlay for win/lose conditions. Plus, I’ll add a restart button. Now it's time to write the file!
write index.html (16474 bytes)
toolResult

Successfully wrote 16474 bytes to index.html

assistant

I've created a complete, self-contained single-file 2048 game at index.html in the current directory. It supports: - Arrow-key and WASD controls - Touch swipe controls - Smooth tile movement and merge animations - Score tracking - Win (2048) and lose states with overlays and actions - New Game button and responsive layout Open or serve index.html 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-5-mini
vendorOpenAI
harnesspi-agent
generated2026-07-22

EVALUATION

3/5 working

2048 grid with score responds correctly to arrow keys and WASD, sliding/merging tiles; click/drag/wheel/enter do nothing as expected.

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 drag1.8%
on wheel0.0%
on enter + space0.0%
on arrow keys2.9%
on w/a/s/d6.8%
frame spread26.7 / 255
console errors0
js errors none

METRICS

runtime78.2s
tokens in6.2k
tokens out5.7k
cached1.0k
cost / run$0.0131