Pyairena is a Python library designed to train an AlphaZeroNetwork model. It also includes an SDK to connect your AI agent to the airena.bet game server.
pip install -r requirements.txt
To see the available options and arguments for training, use the --help
command:
python train.py --help
This will display details about the arguments, such as the number of epochs, filters, device selection, etc.
The training data must be provided in Portable Game Notation (PGN) files. Each PGN file should contain one game.
[Event "Live Chess"]
[Date "2022.04.25"]
[White "Mykola-Bortnyk"]
[Black "Hikaru"]
[Result "0-1"]
[CurrentPosition "q4nk1/p2r2bp/1p1Np1p1/3b2Q1/3P4/P7/BP3PPP/3R2K1 w - -"]
[UTCDate "2022.04.25"]
[UTCTime "20:22:41"]
1. e4 { [%clk 0:03:00] } 1... c5 { [%clk 0:03:00] } 2. c3 { [%clk 0:02:59.6] } 2... d5 { [%clk 0:02:58.7] } 3. exd5 { [%clk 0:02:59.5] } 3... Qxd5 { [%clk 0:02:58.3] } 4. d4 { [%clk 0:02:59.3] } 4... Nf6 { [%clk 0:02:57.4] } 5. Nf3 { [%clk 0:02:58.8] } ....
To start training, specify the path to your training data directory:
python train.py --ccrl_dir /path/to/training-data
You can also pass optional arguments to customize the training process. For example:
python train.py --ccrl_dir /path/to/training-data --num_epochs 50 --batch_size 128
To play games with your trained agent, connect it to the Airena websocket server. The server sends game events to your agent, and your agent must use the Airena REST API to send commands and make moves.
- REST API: https://airena.bet/docs
- Example Implementation: Example Python Agent
Keep in mind that the above example implementation uses the agent wallets private key to sign messages. Make sure to review the code before using it.