Snake Classic Game organises play into sessions. Every session consists of exactly 5 consecutive attempts. A row of 5 dots above the canvas tracks your progress through the session: a yellow dot marks the currently active attempt, and purple dots mark completed ones. Once all 5 attempts are finished, a detailed results panel appears automatically.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ac-unefm/snake-game/llms.txt
Use this file to discover all available pages before exploring further.
Scoring
You earn one point for each food item eaten. The current score is displayed in real time in the HUD asSCORE: N.
Whenever your score exceeds the stored best, the best is updated immediately — both in the HUD (BEST: N) and in localStorage under the key snakeBest — so your record is never lost even if the page is closed mid-session.
Attempt flow
Start attempt 1
From the idle screen, press Enter, Space, any arrow key, or tap the canvas to begin the first attempt. The snake starts near the centre of the grid moving right.
Play
Guide the snake to eat the red food. Each food item eaten grows the snake by one segment and increments the score by 1. The attempt ends immediately if the snake hits a wall or collides with any part of its own body.
Between attempts
After the attempt ends a status message appears showing your score and prompting you to press Enter (or tap) for the next attempt. The completed dot turns purple and the next dot turns yellow.
Per-attempt metrics
Every attempt records the following fields, which are collected into anAttemptRecord object and stored in the sessionAttempts array:
| Field | Description |
|---|---|
score | Food items eaten during the attempt |
maxLevel | Highest level reached before the attempt ended |
duration | Total length of the attempt in milliseconds |
steps | Total cells traversed (one move = one cell) |
maxSpeedCps | Peak speed in cells/second, calculated as 1000 / minTick |
maxSpeedCps reflects the fastest tick interval ever reached during the attempt. For example, if the snake reached level 8 (tick = 45 ms), the recorded peak speed is 1000 / 45 ≈ 22.2 cells/second.
Session statistics panel
After the fifth attempt, the results panel displays two sections: Per-attempt table — one row per attempt showing attempt number, score, max level, duration, steps traversed, and peak speed. The attempt with the highest score is highlighted in purple and marked with a ★ symbol. If multiple attempts share the same top score, the first one is highlighted. Aggregated stats grid — a two-column grid of session-wide figures:| Stat | Description |
|---|---|
| Best score | Highest single-attempt score in the session |
| Average score | Mean score across all 5 attempts |
| Total food | Sum of all food items eaten |
| Total time | Combined duration of all 5 attempts |
| Average duration | Mean attempt length |
| Total distance | Total cells traversed across all attempts |
| Max level (session) | Highest level reached in any attempt |
| Max speed (session) | Peak cells/second recorded in any attempt |
| Efficiency | Food earned per 100 cells traversed (see below) |
sessionAttempts, currentAttempt, all progress dots) and immediately starts a fresh 5-attempt session.
Efficiency formula
Best score persistence
At page load, the stored best is retrieved withreadBestScore(), which reads localStorage.getItem('snakeBest'). Whenever a new best is set during play, saveBestScore() writes it back with localStorage.setItem('snakeBest', value). Both functions wrap their storage calls in try/catch blocks, so a browser privacy setting or a full storage quota will never throw an unhandled error and never crash the game — the best simply resets to 0 for that session.