Return
Snake Game

Main Board

Score: 0
00:00
Difficulty:
Use Arrow Keys or WASD to move
High Score: 0

High Scores

Arcade Origins (1976)

The Snake genre traces its roots to November 1976, when an arcade game called Blockade was developed by the San Diego company Gremlin (also known as Gremlin Industries). Designed by Lane Hauck and Ago Kiss, Blockade was a two player game in which each player controlled a line that grew longer as it moved, leaving a solid trail behind it. The goal was to outlast your opponent by forcing them to collide with a wall or with either player's trail. Blockade was test marketed at the 1976 Music Operators of America expo in Chicago and was released publicly that same month. [Wikipedia, Blockade]

The success of Blockade triggered an immediate wave of clones. Atari released Surround for the Atari 2600 in 1977, one of the console's launch titles, bringing the concept into living rooms for the first time. [Wikipedia, Surround] In 1978, programmer Peter Trefonas wrote the first known home computer version, titled Worm, for the TRS 80 microcomputer and published it through CLOAD magazine. Trefonas subsequently ported the game to the Commodore PET and the Apple II. [Wikipedia, Snake genre] By 1982, the concept had diversified further: Nibbler was a single player arcade game where a snake navigated a tight maze at high speed, and Snake for the BBC Micro introduced relative directional controls and an ever increasing movement speed tied to the snake's length.

The Nokia Revolution (1997)

Snake achieved global fame when Finnish software engineer Taneli Armanto developed a version for the Nokia 6110, which was announced in December 1997 and released to the public in 1998. Nokia had asked Armanto to build several small games for the new handset; he delivered three: Snake, Memory, and Logic. He designed Snake to operate within the Nokia 6110's extreme hardware limits, including a monochrome LCD screen measuring just 84 by 48 pixels. The controls used the phone's number keys, and the gameplay was elegantly simple: guide the snake to eat dots, grow longer, and avoid running into the walls or your own body. [MEL Magazine, Oral History of Snake]

The game spread at an extraordinary scale because it came pre installed on every Nokia 6110 sold worldwide, requiring no purchase, no download, and no setup. Between 1997 and 2007, Nokia shipped over 400 million phones with some version of Snake pre installed, making it the most widely distributed game in history up to that point. Industry analysts estimate that at least 350 million unique people played the game during that decade. At its peak in the early 2000s, more people were playing Snake on a daily basis than any other video game on the planet. [The Original Snake, Who Created Snake] Snake also changed how the industry thought about mobile phones. It proved that a phone could function as an entertainment device, not just a communication tool, a shift that directly influenced the development of downloadable mobile gaming. [The Original Snake, History of Mobile Gaming]

The game continued to evolve alongside Nokia's hardware. Snake II was originally released in 1998 for the Nokia 7110 and was re-released in 2000 on the Nokia 3310, one of the best selling phones of all time at over 126 million units sold. It introduced screen wrapping mechanics and obstacle levels. Snake III brought color graphics to Nokia's Symbian smartphones. Through every iteration, Armanto's original core loop remained intact. [The Original Snake, Who Created Snake] For additional historical context see the detailed genre overview. [Wikipedia, Snake genre]

Modern Interpretations (2000s to Present)

Snake has been reimagined countless times since the Nokia era. One of the most significant reinventions came with Slither.io, a massively multiplayer browser game developed by Steve Howse and released on March 25, 2016. Rather than a single player on a fixed grid, Slither.io drops thousands of players simultaneously into a shared arena where snakes compete to become the longest by consuming glowing pellets and the remains of eliminated opponents. The game topped the App Store shortly after release and was ranked by Alexa as the 250th most visited website in the world by July 2016. [Wikipedia, Slither.io]

Beyond multiplayer adaptations, Snake mechanics have appeared in puzzle games, 3D environments, graphing calculators, smartwatches, and even as Easter eggs inside search engines and mapping applications. The genre has also inspired academic study in artificial intelligence, as Snake's grid based structure makes it a common benchmark for training reinforcement learning agents. [Wikipedia, Snake genre] Despite nearly five decades of technological change, the fundamental appeal of the concept remains unchanged: navigate, grow, and survive. This longevity is a testament to the elegance of the original design first conceived by Lane Hauck and Ago Kiss at Gremlin Industries in San Diego in 1976.

Core Game Loop

The Snake game operates on a continuous game loop that updates at a fixed interval determined by the selected difficulty. Each tick triggers a single movement: the snake's head advances one cell in the current direction, the body segments each shift to the position previously occupied by the segment ahead of them, and the tail segment is removed unless food was eaten that turn. This behavior is most efficiently implemented using a queue or array where the new head position is added to the front and the tail position is removed from the back. When food is consumed, the removal step is skipped for one tick, causing the snake to grow by exactly one segment. [Wikipedia, Snake Gameplay]

Collision Detection

After each movement tick, the game evaluates three possible collision conditions. A wall collision occurs when the new head position falls outside the grid boundaries. A self collision occurs when the new head position overlaps any existing body segment. An important subtlety here is that the tail has not yet been removed when this check runs; if food was not eaten on this tick, the tail cell the snake is vacating is not a valid collision target and must be excluded from the check. A win condition is detected when no empty cells remain on the board, meaning the snake has completely filled the grid. [MDN, Collision Detection]

Input Handling and Direction Queuing

Snake uses a queued input system to decouple player input from the movement tick. When a player presses a direction key, that direction is not applied immediately. Instead, it is stored as a pending direction that takes effect at the start of the very next movement tick. This design prevents two common bugs: it stops the snake from reversing directly into itself if the player presses the opposite direction key, and it handles rapid multi key presses gracefully by processing one direction change per tick rather than all of them at once. The game must also validate each queued direction against the current heading before applying it, discarding any input that would result in an instant 180 degree reversal. [W3C, UI Events]

Procedural Food Placement

Each time the snake consumes a food item, a new one must be placed on a cell that is not occupied by any part of the snake. The placement algorithm builds a list of all empty cells on the grid and selects one at random. If the list is empty, meaning the snake occupies every cell, the player has achieved a perfect game and wins. This approach guarantees that food is never placed on an occupied cell, which would make it unreachable and stall the game. An alternative approach of picking random cells and retrying until an empty one is found is technically equivalent but statistically inefficient when the snake is very long. [Wikipedia, Procedural Generation]

Rendering the Board

The game board is represented internally as a two dimensional grid of cells. On each tick, the renderer iterates over the grid and assigns a visual class or style to each cell based on its current state: empty, snake head, snake body, or food. In browser based implementations this is commonly done using a CSS grid layout where each cell is a div element whose class is updated per tick. Separating the rendering step from the game logic step is good practice because it allows the visual appearance to change without affecting the underlying state, and makes it straightforward to add animations or themes without touching the movement code. [MDN, CSS Grid Layout]

Difficulty Scaling

Easy Mode (8x8 grid): The snake moves once every 250 milliseconds. The snake starts with a length of 3 segments. The total board has 64 cells, so a perfect game requires collecting 61 food items. Each food awards 10 points, giving a maximum possible score of 610 points. This mode is recommended for new players learning the control scheme and building spatial awareness.

Medium Mode (10x10 grid): The snake moves once every 180 milliseconds. The board contains 100 cells. Starting from length 3, the player must eat 97 food items to fill the board, achieving a top score of 970 points. This mode offers a balanced experience that most closely mirrors the feel of the original Nokia Snake. The larger grid gives the player more room to maneuver, while the increased pace demands faster decision making.

Hard Mode (12x12 grid): The snake moves once every 100 milliseconds. With 144 cells total and an initial length of 3, the maximum score is 1410 points (141 food items). At this speed, players have very little time to react to unexpected situations and must think several moves ahead at all times to avoid trapping themselves in a corner. This mode is intended for experienced players seeking a significant challenge.

Score System and Progression

Each food item consumed awards 10 points. The scoring is intentionally linear, with no multipliers, combo bonuses, or time based rewards. This preserves the classic arcade feel and keeps the relationship between skill and score transparent: every food item is worth the same regardless of how long it took to reach or how risky the path was. High scores are stored locally using the browser's localStorage API, which persists data between sessions without requiring an account or server. The top 20 scores are displayed in the sidebar, sorted from highest to lowest. When two scores are equal, the entry recorded earlier retains priority. [MDN, localStorage]

Visual and Thematic Design

The game offers three visual themes that can be cycled using the Theme button. The Regular theme uses a classic blue and green palette. The High Contrast theme uses a strict black and white palette designed to maximize readability for players who benefit from reduced visual complexity or who have color vision deficiencies; this aligns with the contrast guidelines established in the Web Content Accessibility Guidelines. [W3C, WCAG Contrast Minimum] The Dark theme uses a low luminance palette that reduces eye strain in dim environments. Across all themes, the snake head uses gradient styling with small white circles representing eyes, and the food piece is rendered as a red berry with a green stem. The board background uses a repeating pattern that adapts to each theme's color scheme.

Game Timer and Pace Control

A session timer runs independently of the game loop, tracking the total time elapsed since the game began. The timer pauses automatically when the snake dies or when a new game is started, and it can also be toggled manually using the Stop Timer button. This allows a player to pause their timed session without ending the game or losing their score, which is useful for taking a break mid session. The timer is implemented using the browser's setInterval function, which calls a callback at a specified interval (once per second) to update the displayed minutes and seconds. Additionally, stopping the timer also pauses the game movement; the snake will not advance until the timer is resumed. [MDN, setInterval]

Keyboard Input Controls

The game supports two keyboard input schemes: the four arrow keys and the WASD key layout common in PC gaming. Both schemes are registered simultaneously, allowing players to use whichever feels more natural. Input is captured using the browser's keydown event listener, which fires once per key press rather than continuously while the key is held, preventing unintended rapid direction changes. The game strictly prevents the snake from reversing direction into its own body by ignoring any input that would cause a 180 degree turn relative to the current heading. [MDN, KeyboardEvent]