Azalea
playing to learn to play
Azalea is a reinterpretation of the AlphaZero game AI learning algorithm for the Hex board game.
Features
- Straightforward reimplementation of the AlphaZero algorithm except for MCTS parallelization (see below)
- Pre-trained model for Hex board game
- Fast MCTS implementation through Numba JIT acceleration.
- Fast Hex game move generation implementation through Numba.
- Parallelized self play to saturate Nvidia V100 GPU during training
- AI policy evaluation through round robin tournament, also parallelized
- Tested on Ubuntu 16.04
- Requires Python 3.6 and PyTorch 0.4
Differences to published AlphaZero
- Single GPU implementation only - tested on Nvidia V100, with 8 CPU's for move generation and MCTS, and 1 GPU for the policy network.
- Only Hex game is implemented, though the code supports adding more games. Two components are needed for a new game: move generator and policy network, with board input and moves output adjusted to the new game.
- MCTS simulations are not run in parallel threads, but instead, self-play games are played in parallel processes. This is to avoid the need for a multi-threaded MCTS implementation while still maintaining fast training speed and saturating the GPU.
- MCTS simulation and board evaluations are batched according to
search_batch_sizeconfig parameter. "Virtual loss" is used as in AlphaZero, to increase search diversity.
Installation
Clone the repository and install dependencies with Conda:
git clone https://github.com/jseppanen/azalea.git
conda env create -n azalea
source activate azalea
The default environment.yml installs GPU packages but you can choose
environment-cpu.yml for testing on a laptop.
Playing against pretrained model
python play.py models/hex11-20180712-3362.policy.pth
This will load the model and start playing, asking for your move. The
columns are labeled a–k and rows 1–11. The first player, playing X's,
is trying to draw a vertical connected path through the board, while the
second player, with O's, is drawing a horizontal path.
O O O O X . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . X . . . . . .
. . . . . X . . . . .
. . . . . . . . . . .
. . . . X . . . . . .
. . . . . . . . . . .
. . . X . . . . . . .
x . . . . . . . . . . .
o\\ . . . . . . . . . . .
last move: e1
Your move?
Model training
python train.py --config config/hex11_train_config.yml --rundir runs/train
Model comparison
python compare.py --config config/hex11_eval_config.yml --rundir runs/compare <mode1> <model2> [model3] ...
Model selection
python tune.py
References
Metadata
Release files for azalea 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| azalea-0.1.0.tar.gz | 22.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| azalea-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.6 kB
Release files / azalea-0.1.0.tar.gz
| Download URL | azalea-0.1.0.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
510629ce818a6cbede9d2837b42779c682b4f3a7d17f9c40199d6238b638cd45
|
|
BLAKE2b-256 checksum How to use checksums |
a6b20f8876fd07cdace277d2f6c26005b75a1db0ae12410de16646f933b05a38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Release files / azalea-0.1.0-py3-none-any.whl
| Download URL | azalea-0.1.0-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26d37f27c2e118c2f3d742efb87f152a9c24b1c5b691d06e9d4d2c2ea37be9c4
|
|
BLAKE2b-256 checksum How to use checksums |
8310f4a97bbd32aaf1467e489c658ceb7ef841f5ae00dbe9b04375db5f0971f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|