Free browser game

Snake vs AI

Two snakes, one apple supply. Race a pathfinding computer opponent to 15 apples, block its lanes with your body, and do not let it box you in first.

snakegame.org.uk

Loading

One moment.

YOU0
AI0
BEST0

Keyboard: or WASD to steer, P pause, R restart, M mute. Touch: swipe or d-pad.

The machine wants your apples

Snake vs AI puts a second, computer-controlled snake on the board with exactly one job: reach every apple before you do. The AI runs a genuine breadth-first pathfinding search each tick, so it takes real shortest routes, reacts when you cut it off, and punishes lazy lines. First to 15 apples wins the match.

Touching the red snake's body is fatal for you, and the same rule applies to it: if the AI has no safe move, it crashes and respawns a moment later, giving you free seconds of uncontested farming. Forcing those crashes is the heart of high-level play.

How to beat the AI

  • Play the spawn, not the apple. Apples spawn anywhere free. Holding the centre means your average distance to the next apple is shorter than the AI's.
  • Use your body as a wall. The AI routes around your segments. A long body laid across the middle of the board turns its shortest path into a detour.
  • Cut the corner it wants. When you cannot win the race to an apple, drive across the AI's approach lane instead. Either it reroutes and loses time, or it traps itself and crashes.
  • Never trade crashes. The AI respawns; you do not. Your death ends the match regardless of the score.

Match rules

One point per apple for either snake, first to 15 takes the match, and your winning score is saved as your best. If you crash at any point, the AI wins immediately.

FAQ

Frequently asked questions

How does the AI snake decide where to go?
It runs a breadth-first search from its head to the apple every tick, avoiding walls, its own body and yours. When no route exists it picks the safest open direction, and if it is fully trapped it crashes and respawns.
What happens when the AI snake crashes?
It disappears for a short respawn delay and returns at a random free spot with minimum length. You keep farming apples uncontested while it is gone.
What happens if I hit the AI snake?
Contact with the red snake's body is fatal for you and the AI wins the match, whatever the apple count says. Give it a wide berth in corridors.
Can I win by trapping the AI instead of racing it?
Yes. Blocking its lanes with your body until it crashes is a legitimate and effective strategy, and repeated forced crashes usually decide the match.