How the 2048 AI Solver Works: Expectimax Explained
Update — September 23, 2026: the shipped solver was reworked to expand every tile spawn with probability-threshold pruning plus a transposition table, following Robert Xiao’s canonical 2048 AI (nneonneo). The walkthrough and figures below describe this current build; the same numbers, alongside the other games, are on the game-AI benchmark page.
When you turn on Autoplay, the board is handed to a small search algorithm — the 2048 solver — 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 ran its exact search code headless for 250 full games with no human input to see how well it really plays: it reaches the 2048 tile in about 93% of games, pushes on to 4096 in roughly two-thirds, and reaches 8192 in about one game in nine. Here is exactly how it decides, and where it still hits a 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
- Positional (corner-snake) — each square has a fixed rank, and its tile value is multiplied by
4ʳᵃⁿᵏ. Because the weights grow as powers of four, a big tile in the top-ranked corner dominates everything else, so the search is strongly rewarded for stacking value toward that corner in snake order. - Empty squares — every blank cell is worth a flat
200000. That number is deliberately huge: empty space is what keeps future moves legal, so a nearly-full board is scored as almost worthless no matter how large its tiles. - Smoothness — for each pair of horizontal/vertical neighbours the heuristic subtracts
|log2(a) − log2(b)|. Neighbours one doubling apart (mergeable) cost almost nothing; a 2 sitting next to a 512 is punished. Jagged boards score lower.
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ʳ, 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 on the chance layer because every empty cell is a place two different tiles could appear. Instead of cutting corners on accuracy, the solver keeps that under control with three techniques:
- Full, deterministic chance expansion. On a chance layer it expands every empty square — a 2 there with 90% probability and a 4 with 10% — rather than sampling a handful at random. Move selection is therefore deterministic: the same board always yields the same move, and a seeded self-play run reproduces exactly.
- Probability-threshold pruning. Each branch carries the cumulative probability of actually reaching it. Once that product drops below a tiny threshold (
0.0001), the line is scored with a static evaluation instead of being expanded further. This is what makes full expansion affordable: a wide-open board splinters into many low-probability branches that prune themselves shallow, while a tight board with few empties keeps high per-branch probability and is searched deep — exactly where accuracy matters most. - A transposition table. The same position can be reached by different move orders, so scored boards are cached (keyed on the board, guarded by depth) and reused within a turn's search instead of being recomputed.
Depth itself adapts to how full the board is — >8 empties → depth 4, >4 → 5, >2 → 6, otherwise → 7. Wide-open boards carry little danger and enormous branching, so the search stays shallow; as the board fills and mistakes turn fatal, it looks as far as seven plies ahead. Together these keep it responsive — a couple of milliseconds per move — while searching far more thoroughly than a sampling solver could.
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 tile | Rate | Games |
|---|---|---|
| 2048 or better (a "win") | 92.8% | 232 / 250 |
| 4096 or better | 64.0% | 160 / 250 |
| 8192 or better | 10.8% | 27 / 250 |
250 self-play games, standard spawn odds (90% "2", 10% "4"). A second, seeded 250-game run (seed 12345) landed at 92.8% / 65.6% / 12.8% — the same picture within sampling error — with all but one game reaching 1024, a median game of about 2,900 moves, and roughly 1.8 ms of thinking per move on a laptop. No run has reached 16384.
So the honest headline is roughly a 93% win rate to 2048 — strong, watchable, and far clear of casual human play — but it is not a superhuman bot. The steep part of the curve now sits between 4096 (about two games in three) and 8192 (about one in nine), and 16384 has never been reached in testing. The box further down explains why.
Reproduce this. Every number here comes from the shipped solver's exact search code run headless — the same seeded selfPlayGame harness that lives in the public solver-core.js. You can also run the benchmark in your browser on the game-AI benchmark page.
Where the ceiling is now. Reaching 8192 needs a long, near-perfect endgame on a crowded board, and 16384 is essentially out of range. The limit is no longer the search design — it already expands chance nodes fully and reuses positions through the transposition table — but the two live-speed knobs: the depth cap and the 0.0001 pruning threshold. Offline record-setting bots push both far harder (deeper search, a looser threshold, plus refinements like a precomputed row-move lookup table) and spend far longer per move; this solver is tuned to stay instant in a tab you are watching, and trades the very top tiles 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.
Frequently Asked Questions
Is there a 2048 AI solver?
Yes — this page is a free in-browser 2048 AI solver. Tap AI Hint for the best next move, or AI Autoplay to let it play the whole game. No sign-up, and it runs entirely in your browser.
What algorithm does the 2048 solver use?
Expectimax search over the random tile spawns, scored by a corner-snake heuristic that rewards empty squares and a smooth descending order. Every turn it expands all possible spawns — pruning only very low-probability lines — reuses positions through a transposition table, and looks up to seven moves ahead. It is not a generative-AI or LLM wrapper; just deterministic game-tree search.
How good is the 2048 AI solver?
In a fresh 250-game benchmark the current solver reaches the 2048 tile 92.8% of the time, 4096 in 64%, and 8192 in 10.8%, after a rework that expands every tile spawn with probability-threshold pruning plus a transposition table. It is strong and watchable, but not an unbeatable bot. Full per-tile figures, alongside the other games, are on the game-AI benchmark page.
Is there a 2048 best-move calculator?
Yes — the AI Hint button is exactly that. It scores all four directions with expectimax search and names the strongest move, along with why. Tap it any time you're unsure what to play next, without handing control to Autoplay.
Is the 2048 solver free?
The solver is completely free, with no account required. Everything runs client-side in your browser. There is nothing to install and no data leaves your device — the whole search runs locally in JavaScript.
Can I run the solver on my own 2048 board?
The solver plays on this page's own 2048 board rather than importing a position from another site. Start a game here — or turn on Autoplay — to watch it work. There is no separate board-upload feature; the live grid on this page is the only board it evaluates.