The Hint and Auto Play buttons under the board are not canned advice. They run a real search over your actual position, in your browser, and return the move it rates highest. Hint flashes an arrow across the board; Auto Play keeps taking that move until the game ends. Nothing is sent to a server.
Left to itself from a fresh board, that search finishes with a 2048 tile in 100.0% of games. Here is how it gets there.
The obvious tool for a game tree is minimax: assume the opponent picks the worst possible reply and plan against it. 2048 has no opponent. It has a random tile spawn, and the difference matters enormously.
A minimax player treats the spawn as malicious and assumes the 4 always lands in the single worst cell. That produces paranoid, defensive play, because it spends its whole budget guarding against a board that occurs maybe one time in thirty. Expectimax instead takes the average outcome over every spawn that could actually happen, weighted by how likely each one is. It plays the odds rather than the nightmare — the correct model when the randomness is indifferent to you.
So the search alternates between two kinds of node. At a player node it tries all four directions and keeps the best result. At a chance node it places a 2 in every empty cell with weight 0.9 and a 4 in every empty cell with weight 0.1, evaluates each, and averages — the same 90/10 split the game itself uses when it spawns a tile.
The tree cannot be searched to the end of the game, so at the bottom of the search the solver scores the position with four measurements, added together with these weights:
| Term | Weight | What it measures |
|---|---|---|
| Empty cells | 2.7 | Simply how many cells are free. By far the heaviest term — running out of room is how you lose. |
| Monotonicity | 1 | Whether values increase consistently in one direction along rows and columns, rather than zig-zagging. |
| Corner | 1 | A bonus, scaled by size, when the largest tile sits in one of the four corners. |
| Smoothness | 0.1 | A penalty for neighbouring tiles far apart in magnitude — a 2 beside a 512 can never merge, so it is dead weight. |
Three of those four are just the standard human advice written as arithmetic: keep space free, keep things ordered, keep the big tile in a corner. The weights are what turn advice into decisions — the search happily accepts a worse corner position if it buys enough empty cells, and that trade is one people usually get wrong in the other direction.
Every term uses the base-2 logarithm of a tile’s value rather than the value itself, so the gap from 2 to 4 counts the same as the gap from 1024 to 2048. Without that, the largest tile on the board would drown out everything else.
Chance nodes branch once for every empty cell, twice over. An open board with ten free cells has twenty branches at every level; a nearly full one with three free cells has six. Searching both to the same depth would be backwards — the open board is cheap to survive and expensive to search, and the crowded board is the opposite.
So the depth moves with the board:
| Empty cells | Search depth |
|---|---|
| 7 or more | 2 moves ahead |
| 4 to 6 | 3 moves ahead |
| 3 or fewer | 4 moves ahead |
This is the same instinct a good human player has — glance at an open board, slow right down when it gets tight — except applied precisely, and it keeps a hint under a comfortable click-to-arrow delay at every stage of the game.
Across 4 complete games it reached 2048 in 100.0%, with a median score of 38,788 and a median game length of 2,020 moves. The full results, with baselines put those numbers in context.
It is not a state-of-the-art 2048 bot, and it is worth being clear about that. Published solvers reach 32768 by searching much deeper with bitboard representations, precomputed move tables and transposition caches. This one runs on a plain array on the browser’s main thread, keeps no cache between moves, and is capped at four plies so the page never stutters. It is built to answer “what should I do here?” fast enough to feel instant, not to set records.
The most useful way to use Hint is not to follow it. Decide on your own move first, then press it. When the arrow agrees, you have learned nothing you didn’t know — but when it disagrees, you have found a board you are reading wrong, which is where the improvement actually is.
Auto Play is better used as a demonstration than a rescue. Start it from a position you found difficult and watch which direction it protects and which merges it refuses to take. Pressing an arrow key at any time takes control straight back.
The solver is roughly 250 lines of dependency-free JavaScript, served as a plain file at /js/ai.js — readable in your browser’s view-source if you want to check any of this.
Ready to put it into practice?
Play 2048