How to play Snake

Updated September 18, 2026 · The AI Snake guide

Snake has one rule you learn in five seconds and one skill that takes a while: the rule is "don't hit anything", the skill is planning for a body that is much longer than the gap you are aiming at. This guide covers the rules and controls of AI Snake, then the handful of habits that separate a score of 30 from a score of 200.

The rules

Controls

ActionKeyboardTouch
TurnArrow keys or W A S DSwipe the board, or tap the on-screen arrows
Start / pauseSpace or the Play buttonTap the board or Play
New gameRNew game button

Turns are buffered two deep, so a fast up, left makes a tidy one-cell hook. Pressing the opposite of your current direction is ignored — you cannot reverse into your own neck.

Speeds

SettingFeelGood for
ChillRoughly six cells a secondLearning the late game without pressure
NormalRoughly nine cells a secondThe classic pace
FastRoughly thirteen cells a secondReflex practice, and watching the AI finish a board

Early game: don't sprint

While you are short, any route works and the apple is never far. The mistake is to build habits that only work when you are short — diagonal-ish zigzags across the open middle, sharp reversals, cutting corners. Those are exactly the moves that trap a long snake. Practise the late-game habits below from the start, even though you do not need them yet.

Late game: the habits that matter

  1. Hug the edge. A snake running along the wall keeps the whole interior open. A snake wandering through the middle slices the board into pockets, and sooner or later you enter a pocket that is smaller than you are.
  2. Keep a loop. Think of your body as a wall you are building. Always leave a corridor that leads back to your tail, and do not seal it just to grab an apple.
  3. Follow your tail. When there is no safe route to the apple, head toward your own tail. It is the one thing on the board that is guaranteed to be moving out of your way, so there is always room where it has just been. This is also exactly what the game's Safe search AI does when it gets stuck.
  4. Sweep in lanes. The tidiest long-snake pattern is to sweep the board in parallel lanes — down one column, up the next — like mowing a lawn. It is slow, but it never traps you, and it is the human version of the Hamiltonian cycle the AI uses to fill every cell.
  5. Turn before you must. Decide the exit before you enter. If you cannot picture the way out after eating, the apple can wait.

Watch it done. Press Auto on the game and pick Hamiltonian cycle: that is the lane-sweeping pattern, executed perfectly, all the way to 400.

Wrap mode tactics

Wrap removes the walls, which removes your safest lane. In return, the edges become shortcuts — the nearest apple is often through the border. Two adjustments: keep your loop in the interior instead of along the edge, and remember that exiting one side puts your head next to whatever is on the other side, including your own tail.

Scoring

Score equals apples eaten, which equals your length minus the three segments you start with. Your best score is kept separately for Classic and Wrap, in your own browser — nothing is sent anywhere.

Frequently asked questions

What is the goal in Snake?

The goal in Snake is to eat as many apples as you can. Each apple makes the snake one segment longer and scores one point. The game ends when the head hits a wall (in Classic mode) or any part of the snake's own body. On a 20×20 board the maximum length is 400, which fills every cell.

Why do I keep trapping myself?

Because a long snake turns the empty board into corridors. Go for the apple only when you can see the way out afterwards; otherwise take the long way round the edge. A useful habit is to keep your head near your tail — the tail is the one thing on the board that is always moving out of your way.

What is Wrap mode?

In Wrap mode the board has no walls: leave the right edge and you re-enter from the left, leave the bottom and you come back at the top. Only your own body can end the game, and the shortest route to an apple is often through an edge. It also changes strategy: instead of hugging a wall that no longer exists, keep your loop toward the middle of the board.

Can you queue turns?

Yes, you can queue turns. The game buffers up to two direction presses, so a quick up-then-left makes a clean one-cell hook around a corner instead of overshooting. Reversing straight into your own neck is ignored.

More AI opponents to play: Tic Tac Toe, Minesweeper and 2048.

Play AI Snake