Inside the AI

How the 2048 AI Solver Works: Expectimax Explained

By LK Forge  ·  6 min read  ·  Updated Jul 2026

When you turn on Autoplay, the board is handed to a small search algorithm that plays 2048 far better than a casual human. It memorises nothing and follows no fixed script — it re-scores the entire board every single move. We also ran its exact search code headless for 250 full games to see how well it really plays: it reaches the 2048 tile in about 70% of games, pushes on to 4096 in roughly 30%, and — honestly — essentially never reaches 8192. Here is exactly how it decides, and where it hits its ceiling.

The Core Idea: Expectimax Search

2048 is a game against chance: you choose a direction, but the game then drops a new tile on a random empty square. The right tool for games like this is expectimax search. It builds a tree that alternates two kinds of layers. On a max layer the AI tries each of the four moves and keeps the best. On a chance layer it considers where a new tile could appear — a 2 with 90% probability or a 4 with 10% — and averages the results, weighted by probability. By looking several layers deep, the solver does not just grab the move that looks good now; it picks the move whose likely future is strongest, even accounting for unlucky spawns. That distinction is why expectimax handles 2048's randomness far better than a greedy one-move-ahead approach.

Why not minimax? Minimax assumes an adversary that plays the worst tile against you. But 2048's tiles are random, not malicious — so averaging over outcomes (expectimax) models the real game, while minimax would play far too defensively. This is the classic textbook split: minimax for adversarial games like chess, expectimax for games against nature.

The Heuristic: Scoring a Board

Search needs a way to score a board it cannot play all the way out. The whole evaluation is one line — three terms added together:

score = positional + empties × 200000 + smoothness × 4000

Those weights are why the AI keeps its largest tile pinned in a corner without ever being told to — it simply scores those boards higher. This is the snake rank map it uses (darkest = highest weight, the corner everything flows toward):

Ranks boustrophedon ("snake") down to the bottom-right corner. Each rank r contributes 4^r, so the corner is worth 4× its neighbour, 16× the next, and so on.

Searching Deeper When It Matters

Looking further ahead costs time, and the cost explodes with every empty cell because each blank is a branch on the chance layer. The solver makes two pragmatic trades to stay fast enough to run live in your browser:

Those two knobs are the entire reason it feels instant — in the benchmark it spent about 0.5 ms per move — and they are also the reason it plateaus, which we will get to.

From Score to Move

Putting it together, each turn the solver tries all four directions in the order down, right, left, up (a mild tie-break bias toward the bottom-right corner), runs expectimax over each resulting board, and plays the direction with the highest expected score. The AI Hint button runs that search once and reports the winning direction; Autoplay just repeats it on a timer until you stop it or the board locks up.

How Well Does It Actually Play?

Claims like "wins almost every time" are easy to write and easy to disprove, so we measured it. We lifted the solver's exact search and board code out of the page, played 250 complete games to game-over with no human input, and recorded the largest tile each game reached. Results:

Reached tileRateGames
512 or better93.6%234 / 250
1024 or better87.2%218 / 250
2048 or better (a "win")69.6%174 / 250
4096 or better29.6%74 / 250
8192 or better0.0%0 / 250

250 self-play games, standard spawn odds (90% "2", 10% "4"). Median game length ~1,650 moves; ~0.5 ms of thinking per move.

So the honest headline is roughly a 70% win rate to 2048 — strong, watchable, and well clear of casual human play — but it is not a superhuman bot. Notice the cliff between 4096 (about 1 game in 3) and 8192 (never). That wall is not mysterious; it is a direct consequence of the two speed trades above.

Why it stalls at ~4096. Record-setting 2048 bots search deeper (depth 6+), expand chance nodes exhaustively rather than sampling six, and add a transposition table to reuse positions they have already scored. Each of those costs milliseconds per move — fine for an offline benchmark, too slow for a tab you are watching. This solver is tuned for a responsive live demo, and it trades the 8192 ceiling to get there.

The result is a live, watchable run of the corner-snake strategy — the exact pattern the strategy guide teaches — executed move after move in front of you. Turn on Autoplay and you can literally watch the snake weights and the empty-square bonus fight it out in real time.

WATCH THE AI PLAY