Add README.md
Browse files
README.md
CHANGED
|
@@ -18,73 +18,33 @@ task_categories:
|
|
| 18 |
|
| 19 |
# Breakthrough MCVS - Zone Guided AI
|
| 20 |
|
| 21 |
-
**Advanced Monte-Carlo Value Search (MCVS)** engine for the game **Breakthrough** (8x8), powered by a
|
| 22 |
|
| 23 |
-
This
|
| 24 |
|
| 25 |
## Core Idea
|
| 26 |
|
| 27 |
The engine uses:
|
| 28 |
-
- Displacement-based ABC Model with homogeneous coordinates
|
| 29 |
-
- Dynamic Weighted Adjacency Matrices `W = A ⊙ S ⊙ F`
|
| 30 |
-
- Hilbert curve ordering for efficient zone
|
| 31 |
-
- A learned **Zone Database** that stores winning/losing position
|
| 32 |
-
- **Zone Guidance** (`λ-PUCT`) to bias
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
## Files Overview
|
| 37 |
|
| 38 |
| File | Purpose |
|
| 39 |
-
|----------------------------|--------|
|
| 40 |
-
| `breakthrough_mcvs.py` |
|
| 41 |
-
| `
|
| 42 |
-
| `abc_model.py` | Displacement-based ABC Model |
|
| 43 |
-
| `matrix_model.py` | Computes the weighted adjacency matrix |
|
| 44 |
|
| 45 |
|
| 46 |
-
##
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
python breakthrough_mcvs.py
|
| 53 |
-
|
| 54 |
-
This runs continuous self-play + training:
|
| 55 |
-
|
| 56 |
-
1. Generates games using MCVS
|
| 57 |
-
2. Trains the neural networks
|
| 58 |
-
3. Updates and saves the Zone Database
|
| 59 |
-
4. Fully incremental (you can stop and resume anytime)
|
| 60 |
-
|
| 61 |
-
B. Tournament with Online Learning
|
| 62 |
-
|
| 63 |
-
This script runs tournament games while the AI learns (NN or just zone guidance).
|
| 64 |
-
|
| 65 |
-
# With Neural Networks (Full version – Online Learning):
|
| 66 |
-
|
| 67 |
-
bash: python mcvs_vs_uct.py
|
| 68 |
-
|
| 69 |
-
What happens:
|
| 70 |
-
|
| 71 |
-
1. MCVS plays against classic UCT (alternating sides)
|
| 72 |
-
2. Neural Policy and Value networks learn online after every game
|
| 73 |
-
3. Zone Database is updated and saved after each game
|
| 74 |
-
4. Zone guidance turns on automatically after game 1
|
| 75 |
-
5. Creates detailed logs:
|
| 76 |
-
6. breakthrough_full_results.txt — tournament summary
|
| 77 |
-
7. move_log.txt — per-move statistics
|
| 78 |
-
8. learning_log.txt — training progress
|
| 79 |
-
|
| 80 |
-
# Without Neural Networks (Zone-only Ablation)
|
| 81 |
-
To run the faster ablation version:
|
| 82 |
-
|
| 83 |
-
1. Open mcvs_vs_uct.py
|
| 84 |
-
2. Change this line near the bottom:
|
| 85 |
-
|
| 86 |
-
ablation_no_nets=False # ← Change to True
|
| 87 |
-
|
| 88 |
-
```bash
|
| 89 |
-
pip install torch numpy
|
| 90 |
|
|
|
|
|
|
| 18 |
|
| 19 |
# Breakthrough MCVS - Zone Guided AI
|
| 20 |
|
| 21 |
+
**Advanced Monte-Carlo Value Search (MCVS)** engine for the game **Breakthrough** (8x8), powered by a displacement-based **ABC Model** and **Weighted Adjacency Matrices** with **Hilbert-ordered Zone Guidance**.
|
| 22 |
|
| 23 |
+
This implementation adapts the zone-guided MCVS framework to the simple but illustrative game Breakthrough, keeping the same neural architectures and zone-database design used by the chess reference implementation.
|
| 24 |
|
| 25 |
## Core Idea
|
| 26 |
|
| 27 |
The engine uses:
|
| 28 |
+
- Displacement-based ABC Model with homogeneous coordinates to represent piece displacements succinctly
|
| 29 |
+
- Dynamic Weighted Adjacency Matrices `W = A ⊙ S ⊙ F` representing spatial, adjacency and feature similarity
|
| 30 |
+
- Hilbert curve ordering for efficient neighborhood (zone) lookup and compression
|
| 31 |
+
- A learned **Zone Database** that stores winning/losing/drawing position-pattern matrices and provides a k-NN based zone score
|
| 32 |
+
- **Zone Guidance** integrated into PUCT (`λ-PUCT`) to bias MCTS toward favorable zones
|
| 33 |
|
| 34 |
+
The Breakthrough variant uses an internal 8×8 numpy board with lightweight move tuples `(fr, fc, tr, tc)`. Policy outputs are flattened 4096-length move logits (from-square * 64 + to-square), and the value net predicts game outcome in [-1,1].
|
| 35 |
|
| 36 |
## Files Overview
|
| 37 |
|
| 38 |
| File | Purpose |
|
| 39 |
+
|----------------------------|---------|
|
| 40 |
+
| `breakthrough_mcvs.py` | Full MCVS implementation for Breakthrough: game logic, ABC/WeightedMatrix classes, Policy/Value CNNs, Zone DB, MCVS & UCT searchers, self-play and training loop. |
|
| 41 |
+
| `breakthrough_zone_db.npz` | Zone database file: stores Hilbert-ordered matrices for winning, losing, and draw zones used by zone guidance. Created/updated by `breakthrough_mcvs.py`. |
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
+
## Notes
|
| 45 |
|
| 46 |
+
- The policy network maps a 1×64×64 weighted matrix tensor to a 4096-dimensional logits vector for flat move indexing.
|
| 47 |
+
- The zone DB uses k-NN similarity (L1 normalized) across Hilbert-ordered matrices and returns a zone score Z ∈ [-1, 1].
|
| 48 |
+
- `breakthrough_mcvs.py` includes a training loop that performs self-play data generation, incremental training, checkpointing (`breakthrough_checkpoint.pt`) and periodic MCVS vs UCT evaluation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
For implementation details, inspect `breakthrough_mcvs.py`. If you want a shorter quick-start, ask me to add a minimal README usage section with run commands and environment notes.
|