oneshotlm
Compare all models on this prompt →

Snake · gemini-3-flash-preview

Output generated Cost / run $0.0114 Runtime 24.1s

Prompt for this run

Build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state.

⛨ 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

modelgemini-3-flash-preview
vendorGoogle
harnesspi-agent
generated2026-07-22

METRICS

runtime24.1s
tokens in4.8k
tokens out3.0k
cached0
cost / run$0.0114
Transcript · 4 messages
user

Build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state.

assistant
thinking
**Developing Canvas Snake**

I'm focusing on integrating all Snake game logic, including canvas rendering, arrow-key controls, and the growing tail mechanic, directly within a single HTML file. This self-contained approach is progressing well, ensuring all dependencies are handled internally.

→ write index.html (6553 bytes)
toolResult

Successfully wrote 6553 bytes to index.html

assistant
thinking
**Building Snake Game**

I've successfully implemented the core Snake game logic within a single `index.html` file. It features canvas rendering, intuitive arrow-key controls, dynamic snake growth upon food consumption, and integrated score tracking. The game also gracefully handles termination.

The Snake game has been built as requested in a single, self-contained `index.html` file. ### Features: - **Canvas-based Rendering**: Smooth 20x20 grid gameplay. - **Controls**: Arrow keys to navigate. - **Growing Snake**: The snake increases in length each time it consumes food. - **Score Tracking**: Current score is displayed in the UI. - **State Management**: Includes a "Game Over" screen with a final score and a "Play Again" button to restart. - **Self-contained**: No external CSS, JS, or images are used. ### How to play: 1. Open `index.html` in any modern web browser. 2. Use the **Arrow Keys** to control the snake. 3. Eat the red food units to score points and grow. 4. Avoid hitting the walls or your own tail. 5. If you crash, click **Play Again** to restart. **index.html** is now present in the current directory.