Compare all models on this prompt →
Snake · grok-4.20
Output generated Cost / run $0.0224 Runtime 27.8s
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
modelgrok-4.20
vendorxAI · Grok
harnesspi-agent
generated2026-08-01
METRICS
runtime27.8s
tokens in7.7k
tokens out6.1k
cached2.3k
cost / run$0.0224
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
The task is to build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state. It must be a single-page web app in one self-contained f...The task is to build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state. It must be a single-page web app in one self-contained file named index.html with CSS in <style> and JS in <script>, no external resources or CDNs. I need to create index.html that includes everything. First, plan the game: - Canvas for the game board. - Snake as array of positions, moving in grid. - Food as random position. - Arrow keys for direction. - Score based on food eaten. - Collision detection: walls and self . - Game over screen with restart option (space or click). - Maybe pause functionality. - Nice visuals: colors, maybe some styles. Structure: - HTML: header with title and score, canvas, maybe instructions or modal for game over. - Since single file, all inline. - Plain CSS for styling. No Tailwind or CDNs. Keep it simple, dark theme, retro feel for Snake. Game logic in JS: - Grid size, say 20x20 cells, canvas 400x400. - Snake starts with length 3. - Direction: dx, dy. - Food random position.
→ write
index.html (20281 bytes)toolResult
Successfully wrote 20281 bytes to index.html
assistant
thinking
The task is complete. I've built a fully playable Snake game in a single self-contained index.html file. It includes:
The game has been built and saved to **index.html**. Open it in a browser to play. Use arrow keys (or WASD) to control the snake. Eat the apples to grow and increase your score. Avoid walls and your own tail. High score is saved in the browser. Enjoy!