oneshotlm
Compare all models on this prompt →

Tetris · gpt-5.4-nano

Build a playable Tetris on a canvas with all seven tetrominoes, rotation, line clears, increasing speed, a next-piece preview, and score.

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

Build a playable Tetris on a canvas with all seven tetrominoes, rotation, line clears, increasing speed, a next-piece preview, and score.

assistant
thinking
**Creating Tetris in HTML**

I need to create a self-contained index.html file to implement Tetris using JavaScript with a canvas. I want a standard 10x20 grid with 20 visible rows and some hidden at the top. I'll include rotation functionality, incorporating wall kicks and adjusting for collisions. The speed will increase as lines are cleared. I also want to preview the next piece and maintain standard scoring. I'll use requestAnimationFrame and keep track of time based on levels for the drop interval. Lastly, I'll design tetromino shapes as 4x4 matrices for rotation.**Designing Tetris Algorithm**

I'm outlining the Tetris algorithm with a grid of 20 rows and 10 columns. Each cell on the grid will hold a color or be null. The active piece will be represented by its type, rotation, and its x, y position. I think spawning at y = -2 is good for initial positioning, but starting at y = 0 is simpler with a collision check. When a piece collides while moving down, I'll lock it in place, update the grid, and check for game over conditions. I also need to handle line clearing and scoring based on cleared lines and levels, adjusting speed as levels increase.**Finalizing Tetris Mechanics**

I’m refining the Tetris mechanics. For gameplay, I’ll implement soft and hard drops, with soft drop being faster and yielding fewer points, while hard drops lock the piece and award extra points for each row cleared. The controls will include left/right arrows for movement, up for clockwise rotation, and 'z' for counterclockwise. I’ll handle rotation collisions with wall kicks and use a 7-bag randomizer for fair piece distribution. The canvas size will be 320x640, with grid aesthetics like lines and shadows. I'll write the HTML to encompass everything.
write index.html (22038 bytes)
toolResult

Successfully wrote 22038 bytes to index.html

assistant
thinking
**Investigating potential bugs**

I'm looking at a potential bug where drawGrid uses ctx.fillRect from 0,0 to canvas.width and canvas.height. The height matches with ROWS*CELL, which is 20*32=640. But the canvas width is set to 320 while using CELL=32 derived from a constant. If the canvas size changes, that could be problematic, but currently, it's all good at 320. I also need to touch on the Tetris rules—speed increases based on level, with a fallInterval based on 0.85^level-1 and starting at 800. Let’s ensure the file exists. Done!

Created a fully self-contained, playable **Tetris** in **`/tmp/ws/index.html`** with: - **All 7 tetrominoes** (I, O, T, S, Z, J, L) using a **7-bag randomizer** - **Rotation** (with simple wall-kick attempts) - **Line clears** (single/double/triple/tetris scoring) - **Increasing speed** by **Level** - **Next-piece preview** (right panel) - **Score + Level + Lines** - **Canvas rendering** with a **ghost piece** - Controls: **←/→** move, **↑** rotate CW, **Z** rotate CCW, **↓** soft drop, **Space** hard drop, **Enter/P** pause/resume, **Start/Restart** buttons Open `index.html` in your 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.4-nano
vendorOpenAI
harnesspi-agent
generated2026-08-02

EVALUATION

4/5 working

Functional Tetris with falling pieces, next-piece preview, rotation, movement, and scoring UI responding to keyboard input.

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.9%
on wheel0.0%
on enter + space2.2%
on arrow keys1.4%
on w/a/s/d1.0%
frame spread17.2 / 255
console errors0
js errors none

METRICS

runtime64.8s
tokens in10k
tokens out9.5k
cached0
cost / run$0.0139