Snake Game Strategy: How to Get Longer Without Trapping Yourself

Updated Oct 16, 2026 · 9 min read

Snake Play free in your browser →

Snake is about as simple as a game gets. You steer, you eat, you grow, and you lose the moment your head hits a wall or your own body. It takes seconds to learn, but most players stall at the same kind of score game after game, because the thing that ends a game of Snake is almost never a slow reaction. It's a turn you made ten or twenty moves earlier.

This guide explains where those turns come from and what to do instead. It covers how our Snake works, why heading straight for the food stops working once you're long, the one check that doubles your score, and the pattern that fills the whole board. The numbers come from bots playing the game's own code: 1,000 games for each habit, on the same board, Classic speed and food placement you get.

The rules in our Snake

The board is 20 squares by 20, so 400 squares in all. You start as a single square in the middle, heading right. Each piece of food is worth 1 point and adds one square to your length. When you eat, a new piece appears at once on a random empty square.

On the default Classic speed the snake moves one square every 95 milliseconds, a little over 10 squares a second, and the speed never changes during a round (Slow is 140 ms a square, Fast 65 ms; every number in this guide is for Classic with walls on). You only choose the direction: arrow keys or W A S D on a keyboard, a swipe on a phone. You can't turn straight back on yourself; a key for the opposite direction is ignored.

The game ends when your head moves into a wall or into any part of your body. Since the snake starts as one square and every point adds one, a full board means 399 points, the highest score possible.

Two details are worth knowing before anything else.

Quick turns wait in line. The game keeps up to two turns and plays one per step, each checked against the turn before it. Heading right, up then left within the same 95 ms gives up on this step and left on the next: a tight U-turn in two quick presses. A key for the direction you're already going, or straight back the way the previous turn points, is ignored.

The square your tail is leaving still counts as your body. In some versions of Snake you can follow your own tail with no gap, because the tail moves out of the way as the head moves in. Not here: the game checks for a crash before the tail moves.

Two small boards. Left: a four-square snake in a tight ring, its head next to its tail; moving the head into the tail's square is marked as a crash. Right: a five-square snake with one empty square between head and tail; the head moves left, then down into the square the tail has just left, and survives.
Chasing your tail works with a one-square gap. With no gap, it's a crash.

Why chasing the food stops working

The obvious way to play is to go straight for the food by the shortest route. While the snake is short, that's exactly right: there's nothing in the way, and every move toward the food is a move well spent.

We gave a bot exactly that habit: the shortest free path to the food every time, and when no path exists, the move with the most room. Over 1,000 games it averaged 77.2 points, with a median of 78, and its best game reached 135. It needed only 17.1 moves per piece of food, so it was fast. Three times out of four, it died by running into its own body.

Here is how that happens, in a real game the bot played:

A 20 by 20 board. The snake, 60 squares long, has built a box on the right side of the board. The head is at the opening of a red area of 23 empty squares inside the box, with the food just inside.
The moment the game was lost: 23 squares of room for a 60-square body.

The food appeared inside a pocket that the snake's own body had walled in. The shortest path led straight in. Once the head entered, there were 23 free squares for a body 60 squares long, and the walls of the pocket were parts of the body that wouldn't move out of the way in time. The bot ate the food and crashed into itself 24 moves later.

That's how almost every game of Snake ends. The fatal move doesn't look dangerous: there's open space ahead and food right there. The danger is that the space is closed, and the snake is longer than the space.

The one check that doubles your score

The fix is a single question to ask before you go for the food: once I've eaten it, can I still reach my own tail?

Your tail is the one part of your body that is always moving away from you. If there's a path from your head to your tail, you can always follow it, and the snake keeps opening up space behind itself. As long as that path exists, you're never trapped, however long you are.

We gave the second bot that check. It takes the shortest path to the food only when, after eating, its head can still reach its tail. If not, it follows its tail and stays away from the food until a safe route opens up. (If that takes longer than about 40 seconds, it gives up waiting and goes for the food, the way a bored player would.)

Over the same 1,000 games, it averaged 155 points, twice the food-chaser, with a median of 153 and a best game of 392, just 7 short of a full board. It's slower, 29.1 moves per piece of food, because it often takes the long way around. That's the trade: a few extra seconds per point for a much longer game.

You can't run a path search in your head at 10 squares a second, but you can ask the same question in simpler terms:

  • Before you enter a pocket, check that it has a way out that is open now and will still be open when you get there.
  • Don't cut the board in two. When your body runs from one wall to another, the board is split. Make sure the food is on the side with more room, and that you are too.
  • Keep your tail in view. If you know where your tail is and you're heading toward it, you're safe.
  • Leave a gap of at least one square behind your tail when you follow it, because of the tail rule above.

The loop that fills the board

There's a way to play that can't lose: pick a route through all 400 squares that ends where it starts, and follow it forever. The food always appears somewhere on the route, so you always reach it. Your body always lies along the route behind your head, so you never run into it.

A 20 by 20 board with a grey line that runs across the top row, then zig-zags back and forth down through columns 1 to 19, row by row, and climbs back up column 0 to the start. A 150-square snake lies along the loop.
One loop through every square. A snake that follows it can't trap itself.

On a 20 by 20 board, a zig-zag does it: go across the top row, then back and forth down the board one row at a time, leaving the left-hand column free, and climb that column to get back to the top. We ran this bot on 100 games. It filled the board every single time, 399 points.

The catch is time. Following the loop means passing every empty square to reach each piece of food, so a full game took 63.5 minutes on average at Classic speed. The improved version takes shortcuts across the board while the snake is short, never skipping past the food and never into the stretch its body still covers, and sticks to the loop once it covers half the board. It also filled the board every time, in 33.3 minutes.

Bar chart of average score per game. Loop with shortcuts while short: 399. Plain loop through every square: 399. Eat only if the tail stays reachable: 155. Straight at the food: 77.2. Turn at random, never into a wall: 4.3.
Average score from 1,000 games for each habit (100 for the two loops). Turning at random scored 4.3: the snake almost never finds the food.

Nobody wants to play a perfect zig-zag for an hour, but the idea is the most useful thing in this guide: the tidier your body, the safer you are. A snake lying in neat parallel lines leaves the free space in one open block. A snake lying in loops and curls leaves pockets everywhere, and every pocket is a possible trap.

A plan that works

Put together, this is how to get from 50 to 150 and beyond.

  1. While you're short (under about 30), go straight for the food. There's room everywhere and nothing to trap you. Speed matters more than shape here.
  2. From about 30, start packing your body neatly. When you turn, turn back along your own body, one row over, so your body lies in parallel lines. Hug the walls rather than crossing the middle.
  3. Before each meal, ask the tail question. If the food is in a pocket and you couldn't get out after eating, wait. Follow your tail around the open side until the pocket opens.
  4. From about 100, move in zig-zags. Sweep back and forth across the open part of the board instead of cutting toward the food. You'll pass over most of the food anyway.
  5. Never U-turn in a hurry. A U-turn needs a free row beside you; two quick presses do it, so check the row before you press.

Practice

A game of Snake lasts a minute or two, so it's easy to try one habit at a time. Play a few games where you only check the tail question before each meal, and watch how much later the games end. Then try a few where you keep your body in straight parallel lines. If you like games where thinking a few moves ahead beats fast fingers, our Block Puzzle strategy guide is about keeping a board open for the pieces still to come, and there are more quick games in our arcade games.

Play Snake Free, no download, on phone or computer →

More strategy guides