AI and research
How a 2048 AI Works: Expectimax Explained
Quick answer: A 2048 AI uses expectimax search. It tries each move, averages over the random tile that could appear next, scores the boards it reaches, and plays the move with the best average. In our test games, looking four moves ahead reached 2048 in 19 of 20 games, while looking one move ahead never did.

Watch a strong 2048 program play and it can look uncanny. The biggest tile stays in a corner, merges you would have grabbed get skipped, and the board rarely fills up. The method behind it is a search through possible futures, and it takes only a few steps to explain.
This article walks through the approach used by the AI on our Watch AI page, then shows what we measured when we ran it hundreds of times.
What's in this article
1. Why 2048 needs search with chance
Chess programs search a tree where each move leads to the opponent's reply. In 2048 your opponent is a random number generator. After every move the game places a 2 (with 90% probability) or a 4 (with 10%) in a random empty cell. The AI cannot know which cell or which number, so it cannot pick one best branch. It has to weigh all of them by how likely they are.
2. Expectimax in three steps
Expectimax, a variant of the expectiminimax search used for games with chance, alternates between two kinds of decision point.
- Move step: the AI tries up, down, left and right, and keeps only the moves that change the board.
- Chance step: for each resulting board, it considers every empty cell and both possible new tiles, and weights each outcome by its probability.
- Average and choose: it averages the scores of the chance outcomes, then picks the move whose average is highest.
The chance step is where the arithmetic is easy to check. Suppose a move leaves exactly two empty cells. The new tile can land in either cell, so each cell gets probability 1/2, and the tile is a 2 or a 4:
| New tile | Cell | Probability |
|---|---|---|
| 2 | first empty cell | 0.5 × 0.9 = 0.45 |
| 2 | second empty cell | 0.5 × 0.9 = 0.45 |
| 4 | first empty cell | 0.5 × 0.1 = 0.05 |
| 4 | second empty cell | 0.5 × 0.1 = 0.05 |
The probabilities add up to 1. The AI scores the board from each outcome, multiplies by the probability, and adds the results. Doing this for every move, several moves deep, is the whole algorithm. The depth is the number of move steps it looks ahead.
3. Scoring a board without finishing the game
The search cannot play every game to the end, so at its depth limit it needs a quick judgement of how healthy a board looks. Our AI scores a board by adding up a few features for each row and column, much like open-source 2048 programs such as nneonneo's 2048-ai:
- Empty cells score well, because room means options.
- Rows and columns that run in one direction, from large to small, score well, because ordered tiles merge cleanly.
- Equal neighbours score well, because a merge is available.
- A large total of tile values scores slightly worse, which discourages hoarding scattered large tiles.
These are the habits from our strategy guide, written as numbers. The AI does not understand corners as a concept. Keeping the biggest tile in the corner comes out of the ordering rule, because an ordered row is only possible when the biggest tile sits at one end.
4. Making it fast
A row of four tiles has only 65,536 possible states, since each cell holds one of 16 values. The program precomputes, for every possible row, what it looks like after a slide, how many points the slide scores, and its score for the heuristic. Evaluating a whole board then takes eight table lookups, four rows and four columns, instead of any real calculation.
That is why the page can run the AI in your browser without a server. On our test machine the one-move and two-move levels took a fraction of a millisecond per move, and the four-move level took a few milliseconds.
5. What our test games show
We ran each strength level for many games on the 4×4 board and recorded the largest tile in each game. The Casual, Skilled and Expert levels on the Watch AI page use one, two and four moves of lookahead. We also tested three moves.
| Lookahead | Games | Reached 2048 or higher | Typical result |
|---|---|---|---|
| 1 move | 60 | 0 | 128 to 512 |
| 2 moves | 200 | 133 (about two in three) | 1024 to 4096 |
| 3 moves | 100 | 95 | 2048 to 8192 |
| 4 moves | 20 | 19 | 4096 to 8192 |
Each extra move of lookahead made a clear difference, and the biggest jump came from one move to two. These are our own runs with random tiles, not an official benchmark, so the exact numbers will shift from run to run. The 4-move row uses only 20 games because it is the slowest to simulate.
On the small 3×3 board the results change. With three moves of lookahead, our AI reached 256 or higher in 51 of 100 games, including 4 that reached 512, and never went higher than that. That fits with our 3×3 survival guide: the board is too small to build a 2048 tile, so the game uses 256 as its win target there.
What this means for human players
A person can follow the same logic: look ahead, protect empty space, and value order over quick points. The AI does it exhaustively and without fatigue. If you want to see the habits in action, step through a game on the Watch AI page, or read about the mistakes the AI avoids. For the math of whether the game can always be won, see Is 2048 Always Winnable?
Frequently asked questions
What is expectimax in 2048?
Expectimax is a search method for games with chance. It tries each of your moves, then averages over every tile the game might spawn next, weighting each outcome by its probability, and picks the move with the best average result.
Why does looking further ahead help the AI?
Each extra move of lookahead lets the AI see merges and traps that a shorter search misses. In our test games on 4×4, the AI that looked one move ahead never reached 2048, while the one that looked four moves ahead reached it in 19 of 20 games.
Can I watch the AI play?
Yes. The Watch AI page lets you choose a strength level and speed, step through its moves, or take over its board.

