Play

How to Beat the Snake Game: 3 Bots, 3,000 Games

We ran three thousand simulated games to find a route that fills the board every time.

To beat Snake, stop chasing the apple. Walk one closed route that visits every cell and returns to its start, and eat whatever lies on it. Your head then always steps into a cell your tail is about to leave, so you can’t trap yourself.

What 3,000 games showed

We wrote three bots for the 14 by 14 board of our Snake 3D and let each play 1,000 games with the same random apples. A full board is 193 apples.

StrategyBoards filledTypical scoreMoves
Shortest path to the apple0 of 1,00044 (best 81, worst 10)493 on average, then dead
One fixed loop1,000 of 1,0001939,443
Loop with shortcuts1,000 of 1,0001935,269

The first bot plays the way most people do, but it never misses a turn. It still dies with less than half the field covered, because the shortest path folds the body into pockets it can’t leave.

The loop, drawn

Down the first column, up the second, and so on. The top row is kept free as the road home.

Mathematicians call this a Hamiltonian cycle. You only need to remember the shape: columns up and down, one row reserved for the return.

Doing it by hand

  1. While the snake is short, take the shortest way to each apple that still follows the direction of the loop.
  2. As you grow, cut a column short only when the apple is ahead of you on the loop and your tail is well past the point where you rejoin it.
  3. At half the board, stop cutting. Walk the loop to the end.
  4. Never use the reserved row for anything except the way back.

The half-board limit is the one our shortcut bot uses. It cost nothing in safety and cut the number of moves by 44% compared with the plain loop.

Odd boards

A grid needs an even number of cells for a closed loop, because each step flips the colour of a chessboard and you must come back to the colour you left. On an odd-by-odd field, one cell always has to be left out of the loop; you swap which one as you go. If the game lets you choose a size, choose one with an even side.

Does speed matter?

The route stays the same at any speed; you only slip more often. At nine cells a second the plain loop takes about seventeen and a half minutes on our board, and on the slow setting about thirty-seven. For a first full clear, slow is the sane choice. Or press Watch autopilot and see the ending first.