Mini-Chess Zero
Asymmetric TD Learning: A biologically-inspired approach to stable deep reinforcement learning
🎯 Results
| Metric | Before | After |
|---|---|---|
| Win Rate | 3% | 87.5% |
| Q-Value | 70,615,864 | 9.29 |
| Status | Diverging | Converged |
Key Achievement: 1,380× reduction in Q-value explosion through novel stabilization techniques.
🧠 Novel Contribution: Asymmetric TD Learning
Inspired by dopamine neuron asymmetry in biological brains:
# Positive TD errors: Learn cautiously (weight = 0.5)
# Negative TD errors: Learn aggressively (weight = 1.5)
weights = torch.where(td_errors > 0, 0.5, 1.5)
loss = (weights * huber_loss(predicted, target)).mean()
This prevents overoptimistic value estimates while enabling rapid learning from mistakes.
📦 Installation
# Clone repository
git clone https://github.com/your-username/mini-chess-zero.git
cd mini-chess-zero
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install the asymmetric-td package locally
pip install -e .
🚀 Quick Start
Train the Agent
python train_monitor.py
Play Against AI
python play_human.py
Run Web App
cd webapp && python api.py
# Open http://localhost:8000
Run Trading Backtest
cd trading && python backtest.py
📁 Project Structure
mini_chess_rl/
├── src/ # Core RL (87.5% win rate)
│ ├── agent.py # Stabilized DQN
│ ├── environment.py # 5x5 Mini-Chess
│ └── replay_buffer.py
├── asymmetric_td/ # Python Package
│ ├── losses/ # AsymmetricTDLoss
│ ├── agents/ # StableDQN
│ └── utils/ # Gradient, soft update
├── webapp/ # Chess Web App
├── trading/ # Trading Adaptation (+24% return)
├── research/ # Paper, ablation study
└── models/ # Trained models
📊 Ablation Study
| Configuration | Q-Value | Status |
|---|---|---|
| FULL | 9.29 | ✅ Stable |
| NO_ATD | 9.23 | ✅ Stable |
| NO_Q_CLIP | 10.82 | ⚠️ Drifting |
| VANILLA | 12,822 | 💥 Exploded |
The combined stabilization stack is essential—removing all techniques causes catastrophic failure.
🎮 Features
- Asymmetric TD Learning - Novel biologically-inspired loss function
- Gradient Clipping - Prevents explosion (max_norm=10)
- Polyak Soft Updates - Smooth target updates (τ=0.005)
- Q-Value Clipping - Bounds estimates ([-10, 10])
- Reward Centering - Reduces variance
- Action Masking - Legal move enforcement
📈 Neural Network Analysis
The trained agent learned classical chess piece values:
| Piece | Learned Q-Value |
|---|---|
| King | +3.18 |
| Queen | +2.97 |
| Rook | +2.64 |
| Bishop | +2.26 |
| Knight | +1.98 |
| Pawn | +1.86 |
📄 Research Paper
See research/paper/paper_draft.md for the complete paper:
- Title: "Asymmetric Temporal Difference Learning: Biologically-Inspired Stabilization for Deep RL"
- Key Result: 1,380× reduction in Q-value magnitude
🔧 Configuration
Key hyperparameters in src/agent.py:
| Parameter | Value | Description |
|---|---|---|
| GAMMA | 0.95 | Discount factor |
| LEARNING_RATE | 0.0001 | Adam LR |
| TAU | 0.005 | Soft update rate |
| GRAD_CLIP | 10.0 | Gradient clipping |
| ATD_WEIGHTS | (0.5, 1.5) | Asymmetric weights |
📜 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
- Gardner Mini-Chess variant
- PyTorch team
- Schultz (1997) for dopamine asymmetry research
Metadata
Release files for asymmetric-td 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asymmetric_td-0.1.1.tar.gz | 14.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asymmetric_td-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.9 kB
Release files / asymmetric_td-0.1.1.tar.gz
| Download URL | asymmetric_td-0.1.1.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1969cd4946ce3719cf1da69e52e06297d4dd20e3b0005f1992ede1e7e8796b78
|
|
BLAKE2b-256 checksum How to use checksums |
b83982caa8134d222fcd0c52b74891a06fd9993cf006136c5665e14dfe46cbeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / asymmetric_td-0.1.1-py3-none-any.whl
| Download URL | asymmetric_td-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c040c450c161e2c657e95d215571da5433d91707d2942d54519e2230bea9a83d
|
|
BLAKE2b-256 checksum How to use checksums |
4d4ef2239b5c8f69ac7eaf2d548397bba6da9956227cde66035461841ae2d067
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for asymmetric-td 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.