Snake · gemini-3.1-flash-lite
Output generated Cost / run $0.0036 Runtime 9.5s
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.
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
METRICS
Transcript · 4 messages
Build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state.
thinking
**Developing Core Game Mechanics** I'm currently focusing on implementing the fundamental elements for the Snake game. This involves setting up the canvas for rendering, establishing arrow key input for snake movement, and coding the logic for the snake's tail to grow as it consumes food. The food generation mechanism is also a key area of progress.
index.html (4173 bytes)Successfully wrote 4173 bytes to index.html
The Snake game has been created in `index.html`. You can open this file in any web browser to play. **Features included:** * **Canvas rendering:** Smooth grid-based movement. * **Arrow key controls:** Responsive inputs with logic to prevent accidental self-collision (preventing 180-degree turns). * **Growing tail:** Snake increases in length when food is consumed. * **Food spawning:** Food appears at random locations. * **Score tracking:** Updates live as the snake eats. * **Game-over logic:** Detects wall hits and self-collisions. * **Restart functionality:** Resets the game state without refreshing the page.