Pip AI: Training a Championship Backgammon Engine on Consumer Hardware

No cloud GPUs. No H100s. Just a Mac Mini.

Parameters
7.4M
Training Time
51 min/iter
Cloud Cost
$0

Contents

  1. The Challenge
  2. The Pipeline
  3. The Architecture
  4. The Hardware
  5. Results
  6. Lessons Learned
  7. What's Next
  8. Reproducibility

1. The Challenge

Backgammon is a game of perfect information with imperfect odds. Every roll is visible to both players — there are no hidden cards. But the 21 possible dice outcomes per turn create a branching factor that compounds into a game tree of approximately 10^24 nodes. You can't brute-force that. You have to evaluate.

This is why TD-Gammon (1992) was revolutionary. Gerald Tesauro at IBM showed that a neural network could learn backgammon evaluation through temporal-difference learning and self-play — no human labels, just game outcomes. TD-Gammon reached world-class play and reshaped how experts understood the game's opening theory. It proved that neural evaluation functions could master a game where traditional search was hopeless.

Modern backgammon engines have pushed further with deeper networks, more rollouts, and massive compute. But the frontier of competitive AI assumes you have datacenter GPUs, weeks of cloud budget, and infrastructure teams. That raises a question worth answering:

Can you build a competitive backgammon AI on a $700 consumer machine?

No cloud. No H100s. No multi-thousand-dollar training runs. Just a Mac mini sitting on a desk.

Pip AI is the answer — and it's not a toy. It's a fully pipeline-driven, benchmarked, iteratively improved engine that has been climbing through version after version, each warm-started from the last, each generating its own training data from the previous champion's play style.

2. The Pipeline

The flywheel is everything. Each version of Pip AI generates the training data for the next version. It's a self-reinforcing loop: better models generate better positions, which produce better labels, which train better models. The key insight is that supervised learning from rollout labels — not self-play TD(λ) — is the engine that has driven improvement so far.

Position Generation Rust engine 130K positions Monte Carlo Rollouts 3888 / position rayon parallel Neural Net Training PyTorch MPS warm-started Head-to-Head Benchmark 100–1000 games win rate + CI ← The Flywheel: new champion generates positions for the next version →
Figure 1 — The Pip AI training flywheel

Step 1: Position Generation

The current champion plays games against itself. Every position reached during those games is recorded. This isn't random sampling — the positions reflect the actual distribution of positions the current best model encounters, which means the training data is always targeted at the positions that matter. The Rust engine generates 100K contact positions and 30K race positions per iteration.

Step 2: Monte Carlo Rollout Labeling

Each position is evaluated by running 3888 rollouts — 3× the standard 1296 — using the wildbg Rust engine. Rollouts are Monte Carlo simulations: from the current position, play out the game many times with near-optimal play, and measure the win/loss/gammon/backgammon distribution. The result is a label vector of probabilities that represents the "true" equity of the position. The Rust engine uses rayon for data parallelism, distributing rollouts across all available cores.

Step 3: Neural Network Training

The labeled positions are fed into a PyTorch training loop running on Apple's Metal Performance Shaders (MPS) backend. The network is warm-started from the previous champion's weights — it doesn't start from random initialization. This means each iteration begins from an already-strong baseline and refines it. A full training iteration takes 51 minutes on the Mac mini.

Step 4: Head-to-Head Benchmarking

The newly trained model plays 100–1000 games against the previous champion. Win rate is measured with confidence intervals (Wilson score). If the new model wins decisively, it becomes the new champion and generates positions for the next iteration. If not — as happened with v26 — the champion holds and the pipeline adjusts.

The Flywheel

The loop repeats. The new champion generates new positions from its own play style, which differ from the old champion's. The rollouts label those positions. The network learns. The benchmark runs. Each turn of the wheel produces a slightly better, slightly different model — until it doesn't, and you have to change methodology (see Lessons Learned).

3. The Architecture

Pip AI uses a residual convolutional network — the same family of architectures that powers image recognition, but adapted for the 1D structure of backgammon positions. The input is a thermometer-encoded feature vector; the output is a multi-headed prediction of game outcomes, cube actions, and move equity.

Input 207 features 192 point + 15 other Conv1d 207→384 BN+ReLU projection 14 × ResBlock Conv→BN→ReLU Conv→BN→+skip Conv→BN→ReLU Conv→BN→+skip ⋮ Conv→BN→ReLU Conv→BN→+skip Value Head p_win p_gammon_win p_bg_win + 2 loss heads Cube Head 4-class softmax no-double/double/ take/drop/pass Equity Head scalar output move selection v25: HID=384 7.4M params v27: HID=512 ~12M params
Figure 2 — Pip AI network architecture (v25/v27)

Input Features: Thermometer Encoding

The board is encoded as a 207-dimensional vector using thermometer encoding — a scheme where each point on the board is represented by multiple binary threshold features rather than a single count. This gives the network a richer, more learnable representation of piece density.

Residual Tower

The core of the network is a tower of 14 residual blocks, each containing two Conv1d layers with batch normalization and ReLU activations, plus a skip connection. The hidden dimension is the primary scaling knob:

Output Heads

The network has three output heads, each serving a different decision:

Value Head (5 outputs)

Predicts the probability distribution of game outcomes: p_win, p_gammon_win, p_bg_win, p_gammon_loss, p_bg_loss. This is the primary signal for position evaluation.

Cube Action Head (4-class softmax)

Classifies the optimal doubling cube decision: no-double, double/take, double/drop, or pass. This head enables the engine to make cube decisions without separate heuristic logic.

Equity Head (scalar)

A single scalar value used for move selection. During search, the engine generates all legal moves and picks the one with the highest predicted equity from this head.

4. The Hardware

The entire pipeline runs on two consumer Apple Silicon machines. No cloud instances are spun up. No GPU rentals. No per-hour charges. The compute budget is whatever the electricity costs — which is negligible.

Primary — Training

Mac mini M4 Pro

$700
Secondary — Rollouts

Mac Studio M3 Ultra

existing

Training runs on the Mac mini's MPS backend, which provides GPU acceleration through Apple's unified memory architecture. There's no CPU↔GPU data transfer penalty — the tensor data sits in unified memory accessible to both. A full training iteration — forward pass, backward pass, optimizer step, across all batches — completes in 51 minutes.

Rollouts are embarrassingly parallel. Each of the 3888 rollouts per position is independent, so they distribute cleanly across the Mac Studio's 28 cores via Rust's rayon crate. A full rollout batch across both machines takes 12–14 hours. Both machines run overnight; the results are ready by morning.

Total cloud compute cost: $0. The machines were already on the desk. No instances were provisioned. No storage was rented. No data was uploaded. The entire pipeline is local, reproducible, and open source.

5. Results

Each version is benchmarked against the previous champion in head-to-head play. The table below shows the progression from v17 through v27. Win rates are measured with confidence intervals (Wilson score, 95%) where applicable.

Version vs Previous Win Rate 95% CI Games Architecture
v22 vs v17 66.6% — 500 HID=128
v24 vs v22 65.2% — 500 HID=256
v25 vs v24 59.0% 49.2–68.1% 100 HID=384
v26 vs v25 44.0% 34.7–53.8% 100 HID=384 (failed)
v27 vs v25 In Progress TBD TBD HID=512 + 3888 rollouts
40% 55% 70% 80% 50% 66.6% v22 → v17 500 games · HID=128 65.2% v24 → v22 500 games · HID=256 59.0% 49.2–68.1% v25 → v24 100 games · HID=384 44.0% v26 → v25 FAILED · HID=384 win regression 95% CI
Figure 3 — Win rate progression: v22 through v26 (v27 in progress)

Note on v24's benchmark: A 1000-game run showed only 52.9% — the 500-game measurement at 65.2% was less reliable. This is why v25 onward uses 100-game benchmarks with explicit confidence intervals. Fewer games but honest uncertainty.

6. Lessons Learned

Building Pip AI was not a smooth upward curve. The failures are more instructive than the successes.

v26: Same Data, Same Architecture = RegressionFailure

v26 used the exact same architecture (HID=384) and the same data distribution as v25. The result: 44.0% win rate — a regression. Adding more of the same data to the same model doesn't help. The network has already learned what that data distribution has to teach. You need either a methodology change, new data sources, or a bigger model — not more of the same.

The 2-Week Stall: Automation Needs MonitoringInsight

Positions were generated and rolled out, but nobody checked the results for two weeks. The flywheel didn't break — it stalled at the handoff. The rollouts completed, the data sat on disk, and training didn't pick it up. The lesson: automation needs monitoring, not just scripting. A pipeline that runs but isn't observed is a pipeline that silently stops improving.

Diminishing Returns in Supervised LearningInsight

v19 vs v18 was 50/50 — a coin flip. Same data, bigger model, no improvement. Supervised learning from rollout labels has a ceiling. You can keep generating positions and rolling them out, but eventually the network extracts everything it can from that signal. Breaking through requires a different learning paradigm — which is why TD(λ) self-play is the next step.

Warm-Starting WorksWin

Every champion since v22 has been warm-started from the previous champion's weights. v25 warm-started from v24 and jumped to a 59% win rate. Starting from an already-trained baseline means each iteration begins from a strong position and only needs to learn the delta — not relearn the entire game from scratch.

Weight Interpolation for Architecture ChangesWin

When v27 expanded from HID=384 to HID=512, the weight matrices didn't match. Instead of random initialization, the 384-channel weights were linearly interpolated to 512 channels. This lets the bigger model start from v25's hard-won knowledge rather than learning everything from scratch. The bigger model starts smart, not blind.

7. What's Next

The supervised flywheel has carried Pip AI from v17 to v25. The next phase requires a fundamentally different learning signal.

TD(λ) Self-Play Training

The TD-Gammon approach: learn from game outcomes, not supervised labels. Instead of rolling out each position to get a "true" equity, the network plays games against itself and learns from whether it won or lost. Temporal-difference learning with λ-tracing propagates the final outcome back through the game tree, adjusting evaluations toward the actual result. This is the paradigm that produced world-class play in 1992 — and it's the natural next step when supervised labels hit diminishing returns.

Larger Architecture Exploration

v27's HID=512 is the first scaling experiment. If the flywheel continues to turn, deeper or wider networks may extract more signal from the same data. The weight interpolation technique means architecture changes don't waste the knowledge accumulated by previous versions.

Live Deployment on Roll-Cube

The endgame is deployment. Pip AI could power the AI opponents on roll-cube.com, giving human players a genuine challenge from an engine trained entirely on consumer hardware — and proving that the $700 Mac mini on your desk can produce competitive game AI.

8. Reproducibility

Every line of code is open source. The entire pipeline — position generation, Monte Carlo rollouts, neural network training, and benchmarking — is reproducible on any Apple Silicon Mac with Python 3.11 and Rust.

wildbg — Backgammon Engine

The Rust backgammon engine that powers position generation and Monte Carlo rollouts. Licensed under CC0 (public domain).

github.com/phippsbot-byte/wildbg →

pip-ai — Training Pipeline

The Python training pipeline: PyTorch model definitions, MPS training loop, rollout orchestration, benchmarking harness, and the flywheel automation.

github.com/phippsbot-byte/pip-ai →

Requirements: Any Apple Silicon Mac (M1 or later), Python 3.11, Rust toolchain, and patience. The 3888-rollout labeling step is the bottleneck — it's embarrassingly parallel, so more cores = faster. Training itself is 51 minutes per iteration on an M4 Pro.

Play Against Pip AI

Pip AI powers the AI opponents on Roll-Cube. Test your backgammon against an engine trained on a $700 Mac.

Play now Learn strategy