File size: 3,424 Bytes
1f05d29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | ---
license: apache-2.0
language:
- en
- sv
metrics:
- accuracy
tags:
- othello
- reinforcement-learning
- alphazero
- edax
- board-games
---
# Dualist Othello AI
Dualist is a high-performance Othello (Reversi) AI model trained using a **Deep Residual Neural Network** architecture. It was developed as part of a hybrid learning project where a bitboard-based engine (Edax) acted as the "Grandmaster Teacher" to train the neural network via curriculum learning.
## Features
- **Architecture**: 10 Residual Blocks with 256 channels.
- **Input**: 3x8x8 planes (Player bits, Opponent bits, Turn/Constant).
- **Heuristics**: Trained to emulate professional-level Othello gameplay and strategic positioning.
- **Teacher**: Supervised and Reinforcement Learning against the Edax engine (Depth 1-30).
## Model Details
- **Model File**: `dualist_model.pth`
- **Total Parameters**: Optimized for balancing speed and strategic depth.
- **Architecture Class**: `OthelloNet` in `model.py`.
## Installation & Usage
### Prerequisites
- Python 3.8+
- PyTorch
- NumPy
### Quick Start (Inference)
The model can be loaded and used for move prediction. Make sure `model.py`, `bitboard.py`, and `dualist_model.pth` are in your working directory.
```python
import torch
from model import OthelloNet
from bitboard import get_bit, make_input_planes
# Load model
model = OthelloNet(num_res_blocks=10, num_channels=256)
checkpoint = torch.load("dualist_model.pth", map_location="cpu")
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
# Example input (Bitboards)
black_bb = 0x0000000810000000
white_bb = 0x0000001008000000
# Get prediction
input_planes = make_input_planes(black_bb, white_bb)
with torch.no_grad():
policy, value = model(input_planes)
# 'policy' contains move probabilities (log_softmax)
# 'value' is the predicted game outcome [-1, 1]
```
### Optimal Performance: MCTS Integration
While the model provides strong "intuitive" moves (Policy Head), it is designed to be used with **Monte Carlo Tree Search (MCTS)** to reach its full potential. By using the Policy to guide the search and the Value head to prune it, the agent can look ahead multiple turns, making it significantly more "sharp" and strategically sound.
In the provided `inference.py` and the associated Space, we demonstrate how to use 400-800 simulations per move to achieve Expert/Master level play.
### Files Description
- `dualist_model.pth`: Pre-trained weights for the OthelloNet.
- `model.py`: Neural Network architecture definition.
- `game.py`: Core Othello logic and move generation.
- `bitboard.py`: Bit manipulation and input plane processing.
- `mcts.py`: Monte Carlo Tree Search implementation (recommended for play).
- `inference.py`: Example script to run the model on a board state.
## Hugging Face Integration
To push this to your Hugging Face account:
1. Install `huggingface_hub`: `pip install huggingface_hub`
2. Login: `huggingface-cli login`
3. Push files to `brandonlanexyz/dualist`.
https://cdn-uploads.huggingface.co/production/uploads/65fc3d2c2ba04e5ae4f1c1c6/UkwcYLNdpBffFM3JKN1mL.mp4


---
*Created by Brandon | Part of the AntiGravity AI-LAB Othello Project* |