oneshotlm
Compare all models on this prompt →

Snake · gemini-3.1-flash-lite-preview

Output generated Cost / run $0.0040 Runtime 9.7s

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.1-flash-lite-preview
vendorGoogle
harnesspi-agent
generated2026-07-22

METRICS

runtime9.7s
tokens in4.6k
tokens out1.9k
cached0
cost / run$0.0040
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
**Defining the Game's Structure**

I'm solidifying the foundation for this Snake game project. Currently, I'm focusing on the single-file structure, ensuring everything resides within `index.html`. My main priorities right now are the core mechanics: arrow key controls, a growing tail, food generation, score tracking, a proper game-over sequence, and the all-important restart function. The constraints guide the decisions.


**Outlining Implementation Details**

Now, I'm diving deeper into the specifics. I'm visualizing the HTML structure, focusing on a `<canvas>` for the game and containers for UI elements. My CSS plan centers the canvas and adds a dark background. On the Javascript front, I'm setting up configuration variables for things like grid size, and variables for snake and food positioning, velocity, and score.


→ write index.html (4790 bytes)
toolResult

Successfully wrote 4790 bytes to index.html

assistant

The Snake game has been created in `index.html`. You can open this file in any web browser to play. ### Features Included: - **Responsive Gameplay:** Uses the arrow keys to control direction. - **Growing Tail:** The snake grows when it eats food. - **Collision Detection:** The game detects walls and self-collisions. - **Scoring System:** Keeps track of your current score. - **Game Over & Restart:** Provides a clean interface to restart the game upon crashing. - **No Dependencies:** Completely self-contained in one file.