2048

Expectimax AI · it does not stop at 2048

Score0
Best0

Join the numbers and get to the 2048 tile, then 4096, 8192, 16384, 32768 and beyond. The search plays on until no move is left, and the board can hold tiles up to 131072, the largest a 4×4 grid allows.

Game over!

No move is left.

Move 0 / 0
How high can 2048 go, and how this AI worksThe 131072 ceiling, the record holders and the search behind this page

How high can 2048 go?

A tile 2k only appears when two 2k−1 tiles meet, and the second of those has to be built while the first one is already sitting on a square. So the number of squares it takes to ever build 2k is one more than for 2k−1. The chain starts at 4, which the game can spawn directly in a single square. That gives squares(2k) = k − 1:

Tile48…2048163843276865536131072262144
Squares needed12…101314151617

The board has 16 squares, so 131072 (217) is the ceiling and 262144 can never exist. The ceiling is only reachable through the game's 10% chance of spawning a 4: the other 15 squares must hold exactly 4, 8, 16, …, 65536, laid out so that each pair can merge in turn, and the last empty square must receive a 4 rather than a 2. If the game only ever spawned 2s, the cap would be 65536. Playing the whole chain out, the highest possible score is 3,932,100 (OEIS A244056). Nobody, human or program, has reached 131072 without undo; the highest tile that has actually been built in a fair game is 65536.

Why the climb gets harder with every doubling

What has actually been achieved

ProgramMethodResult
ovolve, 2014Iterative-deepening alpha-beta minimax, smoothness and monotonicity heuristics, in the browserAbout 90% of games reach 2048
Nie, Hou, An (CS229), 2016Expectimax, depth 4 with pruning, snake-shaped weight matrix64% reach 2048, 16% reach 4096
nneonneo (Robert Xiao), 2014Expectimax, 64-bit bitboard with row lookup tables, transposition table, probability cutoff; heuristic: empty squares, merges, monotonicity, sum penalty100% reach 8192, 94% reach 16384, 36% reach 32768 (100 games)
Yeh, Wu et al. (NCTU), 2016Multi-stage temporal-difference learning of n-tuple networks + expectimax31.75% reach 32768 over 10,000 games; one game reached 65536, the first ever
Jaśkowski, 2018Delayed temporal-coherence learning, multi-stage n-tuple networks, carousel shapingBest learned player of its time; about 70% reach 32768
Guei, Chen, Wu, 2021Optimistic TD learning, 2-stage 8×6-tuple network + expectimax, tile downgradingAverage 625,377; 72% reach 32768; 0.02% reach 65536
macroxue, 2019–2022Expectimax to depth 8 with a simple evaluation plus very large precomputed end-game lookup tables (27 GB of RAM)Average 711,769; 98.7% reach 16384; 80.5% reach 32768; 3.5% reach 65536 (1,000 games, 17 moves per second)

Rates are the authors' own, measured under their settings. All of these play the standard game: 90% twos, 10% fours, no undo.

The algorithm on this page

The spawn is random, not hostile, so this page uses expectimax, the family behind every strong 2048 player above. Minimax (ovolve's choice) prepares for a 4 in the worst square every single move, which is far more pessimistic than the game and makes the player timid and wrong about probabilities. Expectimax maximises the expected value instead: our move picks the best child; the game's move averages over every empty square with weights 0.9 for a 2 and 0.1 for a 4.

  1. Bitboard. Each square is a 5-bit exponent, each row a 20-bit integer. All four slides, the points they score and the row's heuristic value are precomputed once in 220-entry tables, so a move is four table reads (vertical moves transpose first). Five bits per square is what lets the board represent 65536 and 131072; the classic 4-bit layout stops at 32768.
  2. Evaluation (nneonneo's, applied to the four rows and the four columns): +270 per empty square, +700 per pair of equal neighbours, −47 times the monotonicity penalty ∑|ranki4 − ranki+14| in the better of the two directions, and −11 times ∑ rank3.5, which pushes the big tiles into a corner-anchored chain. A dead board is worth 0 against a baseline of 200,000 per line.
  3. Search. A transposition table of 220 entries, a cutoff that evaluates any branch whose cumulative probability falls under 10−4, and iterative deepening: depth 2 is always finished, then the search goes deeper while the per-move thinking budget lasts. Quiet boards with many empty squares get shallow trees; cramped end-game boards get deep ones, which is where depth matters.
  4. Threads. The engine runs in a Web Worker so the tiles keep animating while it thinks. In this browser it searches roughly ten million nodes per second, so “Strong” reaches depth 6–8 on a crowded board.

What it does not have is the learned n-tuple evaluation or macroxue's end-game tables, which is what the 65536 results rest on. Those need hundreds of megabytes to gigabytes of weights or tables, more than a page can carry.

Measured. Twenty headless games of this engine at the Balanced setting (60 ms per move, same code as the page, Apple M4 Pro, Node) reached 8192 in 19 of 20, 16384 in 14 of 20 and 32768 in 3 of 20, with an average score of 330,168 and a best of 630,208 over about 12,500 moves per game. Twenty more at 50 ms with a slightly greedier time control reached 16384 in 17 of 20 and 32768 in 2 of 20 (average 355,861). Four games at the Strong setting (250 ms, average depth 6.8) reached 32768 twice, with scores of 743,140 and 711,988, and 16384 twice. Expect 8192 and 16384 routinely, 32768 some of the time, and more of it on the deeper settings; 65536 would take hours of luck on top of that.

Playing

Run AI plays until the board is dead, then starts over when auto-restart is on. Hint shows the move the search would make, Step plays it. Arrow keys, WASD and swipes move manually and pause the AI. Space toggles the AI.

References