Skip to content

Add Dots & Boxes engine and AlphaZero self-play loop#13

Merged
krandder merged 1 commit into
masterfrom
codex/implement-dots-and-boxes-engine-with-alphazero
Jan 17, 2026
Merged

Add Dots & Boxes engine and AlphaZero self-play loop#13
krandder merged 1 commit into
masterfrom
codex/implement-dots-and-boxes-engine-with-alphazero

Conversation

@krandder

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a reusable, configurable engine for the Dots and Boxes game that supports arbitrary (rows, cols) board sizes and game-state serialization.
  • Add an AlphaZero-style self-play pipeline to generate training data via MCTS for experimenting with policy/value networks.
  • Expose a small public API so other modules can import the game, MCTS, and self-play utilities easily.

Description

  • Add dots/engine.py implementing DotsAndBoxesConfig, DotsAndBoxesState, and DotsAndBoxes with action mapping, move application, scoring, serialize, legal_actions, render_edges, legal_action_mask, and normalize_policy utilities.
  • Add dots/alphazero.py implementing MCTSConfig, MCTSNode, MCTS, PolicyValueNet interface and a UniformPolicyValueNet baseline, plus select_action and self_play which produces TrainingExample records from self-play using visit-count policies and Dirichlet noise at the root.
  • Add package initializer dots/__init__.py to re-export DotsAndBoxes, DotsAndBoxesState, MCTS, MCTSConfig, PolicyValueNet, UniformPolicyValueNet, TrainingExample, and self_play for convenient imports.
  • MCTS uses configurable num_simulations, c_puct, and root Dirichlet noise blending, and self_play records per-state policy vectors and final game outcome values.

Testing

  • No automated tests were executed as part of this change (no test suite was run).

Codex Task

@krandder
krandder merged commit 80dc072 into master Jan 17, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant