Skip to content

Latest commit

 

History

History
102 lines (67 loc) · 4.43 KB

README.md

File metadata and controls

102 lines (67 loc) · 4.43 KB

tl;dr

Black Queen is a self learning Loosing-Chess engine. It is based on neural networks and utilizes supervised learning as well as reinforcement learning. Therefor it can be trained using either an existing database of anti chess games (for example taken from lichess) or by self-play.

Table Of Contents

Loosing Chess

According to The Classified Encyclopedia of Chess Variants Loosing Chess (also known as Anti Chess) is one of the most popular chess variants. The objective of the game is to loose all your chess pieces. In the following you can see an exemplary game of loosing chess:

Installation

The most straightforward way to install BlackQueen is using pip:

$ git clone https://github.com/mmagorsc/blackqueen/ 
$ cd blackqueen
$ pip install .

Training

In order to use the engine you have to train the BlackQueen first. The neural network can be trained using either supervised learning or reinforcement learning. Pretrained models may be added in future releases.

Supervised Learning

In order to start the supervised learning we have to obtain a database containing anti chess. So far the pgn-format is supported. Databases are available at https://database.lichess.org/antichess/, for example:

$ cd data/games/
$ curl -O https://database.lichess.org/antichess/lichess_db_antichess_rated_2019-05.pgn.bz2
$ bunzip2 lichess_db_antichess_rated_2019-05.pgn.bz2
$ cd ../..

Afterwards the supervised learning can be started using

$ python blackqueen/run.py sl

Reinforcement Learning

The reinforcement learning process consists of three workers: self, opt, eval. First of all the self worker is used to generate training data by self-play. Afterwards the opt worker is used to optimize i.e. train the model using the previously generated training data. Finally the eval worker is used to eval whether the newly trained model is stronger as the last model. If so, the last model will be replaced by the new model. To do so just execute:

python blackqueen/run.py self
python blackqueen/run.py opt
python blackqueen/run.py eval

Usage

The Universal Chess Interface is implemented. Just execute

python blackqueen/run.py uci

to start the UCI. Afterwards launch a GUI of your choice which supports the universal chess interface. A few examples are:

Training Results

The engine has been evaluated using another loosing chess engine. In the following plot you can see the number of wins of BlackQueen in percent depending on the number of training steps.

Contributing

Contributions are welcome. You have an idea, suggestion for improvement or have found a bug? Just create an issue or send a pull request.

License

The project is licensed under the MIT-license. Furthermore the project is based on Zeta36's great Chess-Alpha-Zero library and Akababa's nice fork which are also licensed under the MIT license.