Authors: Tom LABIAUSSE - Amine CHERIF HAOUAT - Sami JALLOULI
Date: Feb/Mar 2024
- Clone the repository:
git clone [email protected]:t0m1ab/alphazero.git
- Install
alphazero
as a package in edit mode (see config inpyproject.toml
):
cd alphazero/
pip install -e .
- You should be able to run tests on the package or print the docs with the following commands in the terminal:
alphazero --test
alphazero --help
- Download the alphazero networks available in our Huggingface Hub using one of the following equivalent commands:
alphazero --download
python alphazero/download.py
All models and configuration files will be stored in a models/
folder by default when loading or training a player.
base
: implement parent classes such as Board, Player, PolicyValueNetwork...players.py
: implement different game strategies (random, greedy, mcts, alphazero, human)mcts.py
: implement Monte Carlo Tree Search (rollout or neural evaluation mode)schedulers.py
: implement temperature schedulers for MCTS during AlphaZero trainingtrainers.py
: implement a trainer for AlphaZerotimers.py
: define timers to perform alphazero training time estimationarena.py
: organize games between players and display results (sequential or parallel mode)game_ui.py
: interface between user and algorithm to play a gamecontests.py
: define specific contests between playersvisualization.py
: define plot functions to create training/evaluation graphsutils.py
: utility functionstests.py
: contains various tests that can be run to check the implementationdownload.py
: run to download alphazero networks stored on a HuggingFace Hubrun.sh
: run to launch a training
registers.py
: define configurations, boards and networks mapping for each game using their nameothello.py
: implementation of the Othello environment, game config and neural network for AlphaZerotictactoe.py
: implementation of the Connect4 environment, game config and neural network for AlphaZeroconnect4.py
: implementation of the Tictactoe environment, game config and neural network for AlphaZero
help.txt
: general informations
othello_board_example.png
: example of Othello 8x8 board with human displayconnect4_board_example.png
: example of Connect4 board with human displaytictactoe_board_example.png
: example of Tictactoe board with human display
Go in the code folder alphazero/
to execute any of the following commands.
Use game_cli.py
to launch a game against the machine. The state of the board will be automatically saved as a PNG file in outputs/
and overwrite itself after each move. Examples of commands can be found below or at the end of game_cli.py
.
python game_cli.py --othello --mcts
python game_cli.py --othello --net alphazero-othello --infos --bot-starts
python game_cli.py --tictactoe --net alphazero-tictactoe --display pixel
python contests.py
Change the contest function called in contests.py
to modify the machine players and/or the game settings.
bash run.sh
Use the options of trainer.py
in run.sh
to change the name of the experiment, the game or the configuration.
Freeze the default configurations as JSON files with the following command:
python trainers.py -f