Snake · glm-4.5
Build a playable Snake game on a canvas with arrow-key controls, a growing tail, food, score, and a game-over and restart state.
transcript · 6 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
The user wants me to build a playable Snake game as a single HTML file. Let me plan this out: 1. HTML structure with a canvas element 2. CSS for styling (in a <style> tag) 3. JavaScript for game logic (in a <script> tag) Game features needed: - Canvas-based rendering - Arrow key controls - Growing tail when eating food - Food spawning randomly - Score tracking - Game over state (when hitting walls or self) - Restart functionality Let me write this as a single self-contained index.html file.
I'll create a complete Snake game in a single HTML file with all the features you requested.
/tmp/ws/index.html (13099 bytes)Successfully wrote 13099 bytes to /tmp/ws/index.html
thinking
I've created a complete Snake game in a single HTML file. Let me verify it was created successfully.
{"command":"ls -la /tmp/ws/index.html"}-rw-r--r--. 1 node node 13109 Aug 1 20:46 /tmp/ws/index.html
thinking
I've created a complete Snake game in a single self-contained `index.html` file. The game includes: **Features:** - **Canvas-based rendering** with a 20x20 grid - **Arrow key controls** (↑↓←→) with input buffering to prevent 180° turns - **Growing tail** - snake grows by 1 segment each time it eats food - **Food spawning** - randomly placed food that respawns when eaten (never on the snake) - **Score tracking** - 10 points per food item, displayed at the top - **Game over state** - triggers when hitting walls or the snake's own body - **Restart functionality** - "Play Again" button to restart after game over **Visual polish:** - Gradient background with modern styling - Glowing effects on snake head and food - Gradient coloring from head to tail - Snake eyes that follow the direction of movement - Subtle grid pattern on the canvas - Smooth game over overlay transition **Game mechanics:** - Snake starts with 3 segments moving right - Food spawns as a glowing red circle - Collision detection for walls and self - Input queueing to prevent quick-reverse crashes The game is fully self-contained with no external dependencies - just open `index.html` in a 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
EVALUATION
Snake game responds to arrow keys, snake dies quickly hitting wall, shows Game Over with Play Again button; WASD doesn't undo prior game-over state.
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.