AlphaZero for 2048
An AlphaZero agent that learns 2048 from self-play alone with zero human gameplay heuristics. A 1-D bitboard engine runs at ~1,000 MCTS simulations/sec (~480k raw engine steps/sec), pairing chance-aware Monte Carlo Tree Search (MCTS) over a ResNet policy/value network with 8× board-symmetry augmentation and a reproducible train/evaluation pipeline. After 20 iterations it reaches 2048 in about 28% of late self-play games.
Problem
The record-holding 2048 agents lean on hand-tuned features: monotonicity, smoothness, empty cells. Change the rules and you retune them. I wanted an agent that is never told what a good board looks like. That means learning an evaluation over something like 10⁵² reachable boards, with a random 2 or 4 dropped in after every move.
Approach
- I replaced the 4×4 NumPy array with a flat 1-D bitboard and a row-shift cache, because NumPy's per-call overhead dominates at this board size.
- Tile powers go in as 16 one-hot channels to ZeroNet, a small residual network. MCTS stays on at inference, since endgames need lookahead the policy alone lacks.
- Random spawns feed the value estimates without expanding chance nodes, so the search stays cheap.
- Batching leaf evaluations across concurrent games lifted GPU utilisation from a few percent to over 80%. That was the biggest throughput win.
- Training used 8-fold board-symmetry augmentation, mixed precision, a cosine learning rate and a replay buffer, all in a reproducible pipeline.
Results
- After 20 self-play iterations, about 20 hours on one workstation with a single GPU/MPS device, late-stage self-play reaches 2048 in about 28% of games and 4096 in about 1 in 17. In the first five iterations it rarely cleared 512.
- Policy cross-entropy fell from ~ln 4 to ~0.5, value MSE from ~0.75 to under 0.15, with no collapse along the way. The 1-D engine is what made an overnight run possible instead of a long weekend.
Limits
- This is nowhere near the TD + Expectimax record (32,768 in over 30% of games). What it has instead is a policy taught by nothing but play.
Metrics
- late games reach 2048
- 28%
- MCTS simulations (~480k raw steps/s)
- ~1,000/s
- engine vs NumPy
- 20–51×
- ZeroNet parameters
- ~2.5M
- one workstation, single GPU/MPS
- ~20 h
Architecture
- 1-D bitboard engine + row-shift cache
- ZeroNet (8×128 residual)
- Chance-aware MCTS (~1,000 sims/s)
- Batched concurrent self-play
- Replay buffer + 8-fold D4
From the report
From chapter 6 of the report: loss over 20 iterations, engine throughput against NumPy, and the max-tile distribution moving right as training goes on.


