Project P12

AlphaZero from scratch

How can a system learn to play at an expert level without human knowledge, using only tree search, a neural network, and self-play, and how can we demonstrate that it really plays well?

stages
9
duration
16 h 40 min
concepts
21
available in English
9 / 9
completed by you
0 of 9

Where it fits

Leads to

This completes the path.

Overview

A project building a complete AlphaZero system on a laptop. Start with a Connect 4 bitboard engine and an exact solver as an oracle, then progress through pure MCTS with Elo estimation, a residual policy-value network, network-guided MCTS with PUCT and batched GPU evaluation, and a self-play system with parallel workers and an inference server. Train toward near-perfect play measured against the solver, incorporate efficiency improvements such as Gumbel selection and KataGo techniques, generalize to Othello against an open engine, and finish with MuZero, which also learns the game model.

Why it matters

AlphaZero is one of your main goals and brings together much of the curriculum: search, bandits, residual networks, reinforcement learning, parallel systems engineering, and statistical evaluation. Choosing Connect 4, a solved game, allows something uncommon in reinforcement learning: measuring agent quality against exact ground truth. MuZero connects to planning with learned models in robotics and agents.

Stages 9

  1. 01Connect Four engine and exact solverImplement Connect 4 with bitboards and a negamax solver using alpha-beta pruning, center-first move ordering, null windows, and a transposition table. The solver, validated with public test positions of known value, will be the oracle measuring the agent throughout the project. GPUAdvanced110 min
  2. 02MCTS with UCT and Elo measurementImplement MCTS with UCT and random rollouts and build evaluation infrastructure for the project: tournaments between agents with varied openings, Bradley-Terry Elo fitting with bootstrap intervals, and optimal-move percentage according to the solver. Measure how MCTS strength scales with simulation count. GPUAdvanced100 min
  3. 03Residual policy-value networkDesign the network: input planes from the player perspective, a small residual tower, a policy head over columns with an illegal-move mask, and a value head. Before self-play, validate it through supervised learning on solver-labeled positions, using horizontal board symmetry for augmentation. GPUAdvanced100 min
  4. 04Network-guided MCTS: PUCTReplace random rollout with the network: policy supplies priors, value evaluates leaves, and selection uses PUCT. To use the GPU, batch evaluations with virtual loss and parallel searches, and add root Dirichlet noise and the temperature used in self-play. GPUAdvanced110 min
  5. 05The self-play systemBuild the systems side: CPU-core search workers, a GPU inference server batching their requests, a game buffer with policy and value targets, a trainer consuming data and publishing network versions, and orchestration to keep the system working overnight without intervention. GPUAdvanced120 min
  6. 06Training AlphaZero and measuring it against the truthTrain the agent from scratch over several nights and track its progress using what few RL projects have: the percentage of optimal moves according to the solver, alongside Elo against fixed opponents. Monitor training health signals and analyze positions where the agent still makes mistakes. GPUResearch110 min
  7. 07Less compute: Gumbel AlphaZero and KataGo tricksWith limited compute, efficiency matters. Implement Gumbel-top-k root selection and sequential halving, which guarantees policy improvement with very few simulations, and test KataGo techniques such as random simulation limits and auxiliary targets. Compare them in an equal-compute ablation design. GPUResearch110 min
  8. 08A second game: Othello against an open engineDemonstrate system generality by bringing it to 8-by-8 Othello with a generic game interface for state, moves, dihedral-group symmetries, and encoding. Without a complete solver, evaluate the agent against a strong open engine at calibrated levels and compare learning efficiency with Connect 4. GPUResearch120 min
  9. 09MuZero: planning with a learned modelTake the final step: an agent that does not know the rules. Implement MuZero's representation, dynamics, and prediction networks, search in latent space, and training unrolled for K steps with policy, value, and reward targets. Train on Connect Four, evaluate against the solver, and compare quality and compute with AlphaZero. GPUResearch120 min

Final deliverable

Game platform with AlphaZero and MuZero

A generic self-play system with near-perfect Connect 4 verified against the solver, Othello evaluated against an open engine, MuZero compared at equal compute, and a report with all curves and intervals.

Check what you already know

  • Implement a game with bitboards and a negamax solver with alpha-beta pruning and a transposition table
  • Implement MCTS with UCT and estimate the relative Elo of two agents with an interval
  • Design the policy-value network with board-symmetry data augmentation
  • Implement PUCT with Dirichlet noise and batched evaluation using virtual loss
  • Design a self-play system with parallel workers and a GPU inference server
  • Explain how MuZero learns a dynamics model and plans with it

References