PERFECT SNAKE AI
Classic AI
PERFECT!

Race: four methods, same apples

Every snake makes one move per tick and gets the same apple sequence. The fewer moves a method needs, the sooner it fills its board.

Board filled vs. moves (this race)

Scoreboard

0 races on this board size

Statistics

Every finished game is recorded on this device: from Watch, Race, benchmarks and the marathon.

Games recorded on this board size
0
0 games in total
Fastest guaranteed method
โ€“
Run a benchmark to find out
Methods with a proof
โ€“
share of games won by the three proven methods

Average moves to fill the board

fewer is better ยท won games only

Win rate

share of games where the board got filled

All numbers

Why it always wins

A Hamilton loop is a closed route that visits every cell exactly once. If the snake's body lies along such a loop as one unbroken piece, the snake can always just follow the loop: the cell ahead is either empty or the tail that is about to move away. It can never crash, and it reaches every apple within one lap.

Before every move the AI checks that such a loop still exists after the move. That is a calculation, not a guess.

The four methods

    Good to know

    • Only even board sizes: an odd ร— odd board has no Hamilton loop, so no method can guarantee a win there.
    • The marathon keeps playing in a background thread, so you can leave this tab open (for example while you are at work) and come back to more statistics.
    • Statistics are stored in this browser only.