Add README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
pretty_name: Chess MCVS - Zone Guided AI
|
| 4 |
+
tags:
|
| 5 |
+
- chess
|
| 6 |
+
- game-ai
|
| 7 |
+
- monte-carlo-tree-search
|
| 8 |
+
- reinforcement-learning
|
| 9 |
+
- zone-guidance
|
| 10 |
+
- adjacency-matrix
|
| 11 |
+
- hilbert-curve
|
| 12 |
+
- abc-model
|
| 13 |
+
- pytorch
|
| 14 |
+
- numpy
|
| 15 |
+
task_categories:
|
| 16 |
+
- other
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Chess MCVS - Zone Guided AI
|
| 20 |
+
|
| 21 |
+
**Advanced Monte-Carlo Value Search (MCVS)** engine for the game **Chess** (8x8), powered by a novel **Displacement-based ABC Model** and **Weighted Adjacency Matrices** with **Hilbert-ordered Zone Guidance**.
|
| 22 |
+
|
| 23 |
+
This repository implements a complete zone-guided reinforcement learning system, including self-play training, neural networks, and comparative tournaments against classic UCT.
|
| 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 retrieval
|
| 31 |
+
- A learned **Zone Database** that stores winning/losing position patterns
|
| 32 |
+
- **Zone Guidance** (`λ-PUCT`) to bias search toward promising zones
|
| 33 |
+
|
| 34 |
+
For more information please refer to the paper at: https://doi.org/10.13140/RG.2.2.18795.09764
|
| 35 |
+
|
| 36 |
+
## Files Overview
|
| 37 |
+
|
| 38 |
+
| File | Purpose |
|
| 39 |
+
|----------------------------|--------|
|
| 40 |
+
| `chess_mcvs.py` | Main implementation: game logic, ABC model, Zone Database, MCVS, neural networks, incremental training |
|
| 41 |
+
| `mcvs_vs_uct.py` | 200-game tournament between MCVS and UCT with detailed logging and online learning |
|
| 42 |
+
| `abc_model.py` | Displacement-based ABC Model |
|
| 43 |
+
| `matrix_model.py` | Computes the weighted adjacency matrix |
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
## Requirements
|
| 47 |
+
|
| 48 |
+
## How to use:
|
| 49 |
+
|
| 50 |
+
A. Incremental Training
|
| 51 |
+
|
| 52 |
+
python chess_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. chess_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 |
+
|