Checkmating One, by Using Many - QueensGambit/CrazyAra GitHub Wiki
Instructions for reproducing the results in the paper
Game phase extraction for training in game_phase_detector.py.
Game phase extraction for MCTS in the board.cpp get_phase function. Change first if condition to (num_phases == 3 && true)
to use lichess phase definition when using three experts.
Workflow of training one phase expert network:
- Gather dataset pgn files and specify default_dir in main_config.py. The pgn files should be placed in <default_dir>/pgn/<set_type>, see main_config.py for more details.
- Specify phase and phase_definition (either "lichess" or "movecountX") in main_config.py
- Generate planes (input representation) from pgn files with convert_pgn_to_planes.ipynb
- Use train_cnn.py to train the expert
- tc.seed=9 was used for all our experiments
- Specify tc.export_dir for the model export directory
- Adjust phase_weights as needed. Use 1.0 for equal weights for all phases.
- For the weighted learning approach, set phase in main_config.py to None and only adjust phase_weights in train_cnn.py
- Repeat process for each expert
Workflow to use phase experts as an MoE agent in MCTS:
- Copy .onnx and .tar files from the best-model folder of each expert training export directory
- Paste .onnx and .tar files from expert i to a model directory, e.g. /data/model/ClassicAra/chess/<moe_name>/phase<i> (one phase<i> folder for each phase/expert)
- Build ClassicAra binary, see Build Instructions
- Launch the ClassicAra binary.
- Specify the model directory as needed, e.g. "setoption name Model_Directory value /data/model/ClassicAra/chess/correct_phases"
- Specify Batch_Size as needed, e.g. "setoption name Batch_Size value 8"
- Specify GPU as needed, e.g. "setoption name First_Device_ID value 0"
- Generate .trt files by executing the "isready" command
- Run Cutechess match to compare different approaches, see run_cutechess_experiments.py for exemplary cutechess commands