Skip to content

Akulen/AlphaGateau

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enhancing Chess Reinforcement Learning with Graph Representation

How to Run

Step 1: Create a venv and download the requirements

requirements.txt installs the cuda version of jaxlib by default, which requires a GPU and cuda.

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Step 1.5: Activate the venv

. venv/bin/activate

Step 2: Run the example

By default, an AIM server is expected to run on port 53800. It is possible to run AIM on a remote server, and to use an SSH port tunnel to make it available locally with the command ssh -N -L 53800:localhost:53800 <remote server>.

Running

python train.py

will start to train a full model. The run can be configured by editing the config dictionary in train.py. If the 75% of allocated GPU memory is an issue, it is possible to pass XLA_PYTHON_CLIENT_ALLOCATOR=platform as an environment variable.

python ranking.py <model>

will select 5 opponents for the model run <model> (using the matching folder name in models, e.g. chess_2024-08-20:00h13), and run matches. Those matches are saved as pgn in tournaments/ranking matches, the outcomes are saved in rankings.json, and estimated ELO ratings are evaluated and stored for each player.

Book explorer

The file book.py can be used to explore all the saved pgn games. For example:

python book.py tournaments/ranking\ matches/ -p="chess_2024-08-20:00h13-499" -o="e2e4 c7c5 Nb1c3 e7e6 Ng1f3 Nb8c6 d2d4 c5d4 Nf3d4 Ng8f6 Nd4c6 b7c6 e4e5 Nf6d5 Nc3e4 Qd8c7 f2f4 Qc7b6"

Will return one of the games included in the appendix of the paper.

Experimental

As the current conda environment is really hard to replicate, a new environment configuration has been added with pixi.

It can be run simply using:

pixi run train <args>
pixi run rank <args>
pixi run book <args>

However, it has not been fully tested yet, and might run into some incompatibility issues using models trained on a previous version of the code against the updated dependencies.

About

Enhancing Chess Reinforcement Learning with Graph Representation

Resources

Stars

Watchers

Forks

Packages

No packages published