Skip to content
poozee

Strategy Guides

How to Win the Snake Game: The Loop That Fills the Board

Yes, you can beat Snake: fill every square. We played 500 test games per strategy to measure what wins, how long it takes, and the maximum score.

By Poozee EditorsUpdated 9 min read

Yes, you can beat Snake: you win by filling the whole board. On Poozee's Snake the board is 18 by 18, so your snake has to grow from 3 squares to all 324, which takes 321 apples. The reliable way to do it is to follow a loop that passes through every square, and in our tests a bot that did exactly that won all 500 games.

The catch is time. The loop alone took about 26,000 steps, or 45.5 minutes on Classic speed. Below are the measured numbers for every speed, a smarter version that halves the time, and what happened to bots that just chased the apple.

What "beating Snake" means on Poozee

The snake starts 3 squares long and grows by one square for every apple, so the numbers are fixed:

  • 324 squares on the board (18 x 18).
  • 321 apples to fill it.
  • The game ends the moment the snake covers every square. The last apple still scores, the board shows "You win!" and "You filled the whole board.", and if the score beats your best it's saved in your browser like any other best score.

That makes the maximum score easy to work out, because every apple is worth the same at a given speed:

Speed Points per apple Steps per second Maximum score
Chill 10 6.7 3,210
Classic 20 9.5 6,420
Turbo 30 14.3 9,630

A perfect score is a full board. There is no bonus for speed, so the only way to score higher than someone else at the same speed is to eat more apples.

How we measured

We wrote bots that play Poozee's Snake with the game's own code: the same rules, the same 18x18 board and the same random apple placement, with a fixed random seed for each game so the results can be checked. The bots only choose which way to turn. Each one played the same 500 games (seeds 1 to 500):

  • The loop: follows one fixed route through all 324 squares and never leaves it.
  • Loop with shortcuts: follows the same route but cuts across it toward the apple whenever that is provably safe (the rule is explained below).
  • Loop with shortcuts until half full: the same, but only while the snake is shorter than 162 squares, half the board. After that it sticks to the loop.
  • Apple chaser: heads straight for the apple and only avoids crashing on the very next step.
  • Careful chaser: heads for the apple too, but never moves into an open area with fewer squares than the snake is long. That's the "don't split the board" rule from our Snake high score tips.

A step is one square of movement. A turn is any step where the direction changes: one key press or swipe.

The results

Strategy Full boards Average steps Time on Classic
The loop 500 25,992 45.5 min
Loop with shortcuts 500 24,796 43.4 min
Shortcuts until half full 500 13,810 24.2 min
Apple chaser 0 - -
Careful chaser 0 - -

Every strategy built on the loop filled the board in all 500 games. Both chasers failed every time. The interesting part is the middle row: taking shortcuts all game long saved only 4.6% of the steps, while taking them only in the first half saved 46.9%. It's a lot of steering either way: the plain loop needed 2,888 turns on average, shortcuts all game 3,899, and shortcuts until half full 2,076. The sections below explain why.

The loop that always wins

A route that visits every square exactly once and comes back to its start is called a Hamiltonian cycle. Here is the one our bot used on Poozee's 18x18 board. Each arrow shows which way to go from that square:

↓ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
↓ → → → → → → → → → → → → → → → → ↑
↓ ↑ ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←
→ → → → → → → → → → → → → → → → → ↑

It's the 6x6 loop from tip 5 of our high score tips, turned upside down and stretched to 18 rows. The left column is a lane going down, and the other 17 columns are mowed row by row from the bottom up. We flipped it for one reason: your snake starts on the 10th row from the top, on squares 5 to 7, heading right, and on this loop the 10th row runs right. You're on the loop from the very first step.

Why it can't fail: the snake's body always lies on the squares just behind its head on the loop. The next square ahead is either empty or the square your tail is leaving on that same step, and on Poozee moving into the square your tail is leaving is safe. So the loop never runs into anything, all the way to a full board.

Why it's slow: you can't go to the apple. You wait for the loop to bring you there. When the snake is short, the apple is about half a lap away on average, roughly 160 steps for a single apple. Adding up the average wait for all 321 apples gives exactly 26,001 steps, and the 500 games averaged 25,992, with the fastest finishing in 22,915 and the slowest in 28,726.

Here's what that means at each speed:

Speed The loop Shortcuts until half full
Chill 65.0 minutes 34.5 minutes
Classic 45.5 minutes 24.2 minutes
Turbo 30.3 minutes 16.1 minutes

Pro tip: The hard part for a person is timing. At the end of each row you need two turns on back-to-back steps (for example up, then left). Poozee queues quick presses, so tap both keys as a pair, but only once your head is on the last square of the row. That leaves you one step to do it in: 150 milliseconds on Chill, 105 on Classic and 70 on Turbo.

Shortcuts: take them early, then stop

A shortcut means stepping off the loop into a neighboring square that the loop would only reach later. The bot follows three rules:

  1. Only step into a square further ahead on the loop, so you skip squares instead of doubling back.
  2. Never skip past your own tail, so every square you skip is empty.
  3. Never skip past the apple.

Rules 1 and 2 are what keep you alive: your body stays in loop order, so the next square of the loop is always free, exactly as in the plain loop. Rule 3 just keeps the shortcut useful, because skipping the apple means a whole extra lap. On the loop above, almost every shortcut is a step up: in the first 100 games, 97% of the bot's shortcut steps were. When the apple is in a higher row, go straight up the column toward it instead of finishing each row.

The surprise is what happens if you keep doing it all game. Every shortcut leaves skipped squares behind you, and sooner or later an apple appears in one of them. Then the only safe way back is the long way around the whole loop. The table shows the average steps per apple at each stage of the game:

Snake length The loop Shortcuts all game Shortcuts until half full
3 to 50 148.5 24.0 24.0
50 to 100 125.7 38.3 38.3
100 to 162 97.2 64.0 64.0
162 to 200 72.4 87.0 75.0
200 to 250 50.5 106.4 50.5
250 to 300 25.3 126.5 25.3
300 to 324 6.7 118.1 6.7

Shortcuts make the first half of the game almost three times faster (7,012 steps instead of 19,292), then make the second half much slower than the plain loop. Stopping at half the board keeps the gain and avoids the cost. In a smaller run of 100 games, stopping at a quarter of the board averaged 17,190 steps and stopping at three quarters averaged 16,721, against 13,837 for half on the same games, so half is a good place to stop.

If you want to build this as a bot, how the perfect Snake AI works has the rule as code, random maze loops, more places to stop, and how it compares with a path-finding AI. To write the game itself first, how to code Snake in JavaScript builds it in one HTML file and ends with the loop bot.

You can't see the snake's length during a game, but you can see your score. Half the board is 162 squares, or 159 apples, so stop taking shortcuts once your score reaches 1,590 on Chill, 3,180 on Classic or 4,770 on Turbo.

Why chasing the apple loses

Most players steer straight for each apple. Our apple chaser did the same, and it filled the board in 0 of 500 games. It ate a median of 25 apples before trapping itself (a 28-square snake, under a tenth of the board), and its best game ended after 60.

The careful chaser did better but still never won. Refusing to enter any space smaller than itself raised the median to 56 apples and its best game to 98. Its weakness is that it only checks the space it's entering right now, not whether that space will stay open. In 6 of its 500 games it even ended up circling forever without ever reaching the apple, which our test counts as a loss.

So the habits from the high score tips, like following your tail and not splitting the board, are what push your score higher. Filling the board takes a plan for every square, and the loop is that plan.

A plan to beat Snake on Poozee

  1. Practice on Chill. You get 150 milliseconds for each turn instead of 70 on Turbo, and the loop is the same at every speed.
  2. Start on the loop. Your snake begins heading right on the 10th row, which is already part of the loop in the diagram above.
  3. Take shortcuts up the columns while your score is below 159 apples' worth (1,590 on Chill), and only when every square you'd skip is empty.
  4. Then follow the loop square by square until the board is full. Don't chase the apple: it always comes to you within one lap.
  5. Don't panic over an early turn. Turning up one square too early at the end of a row is just a shortcut, and it's still safe as long as every square you skipped was empty. Carry on along the loop from where you are.

Plan on about 2,000 turns even with shortcuts, so don't start a full-board run when you only have a few minutes.

Keep playing

Ready to try it? Start a game of Snake on Chill and run the loop for a few laps before you worry about apples. If you'd rather go for a big score than a full board, our Snake high score tips cover the habits that keep a long snake alive. And if you like games you can win with the right plan, how to win 2048 shows the same kind of corner-and-route thinking.

Frequently asked questions

Can you actually beat Snake?

Yes. You beat Snake by filling the whole board. On Poozee that means growing from 3 squares to all 324, which takes 321 apples, and a bot that followed a loop through every square did it in all 500 of our test games.

What is the max score in Snake?

On Poozee it's 321 apples times the points per apple: 3,210 on Chill, 6,420 on Classic and 9,630 on Turbo. Nothing can score more, because the game ends the moment the board is full.

How long does it take to beat Snake?

Following the loop all the way took 25,992 steps on average, about 45.5 minutes on Classic. Taking shortcuts until the snake fills half the board cut that to 13,810 steps, about 24.2 minutes on Classic or 16.1 on Turbo.

What happens when you fill the board in Snake?

On Poozee, the last apple's points are added, the game stops and the board shows "You win!" with your score. If it beats your best, it's saved as your new best score in your browser.

Can you win Snake just by chasing the apples?

Not in our tests. A bot that headed straight for every apple never filled the board in 500 games and usually trapped itself after about 25 apples. Even a bot that refused to enter spaces smaller than itself never got past 98.