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.
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:
The most straightforward way to install BlackQueen is using pip:
$ git clone https://github.com/mmagorsc/blackqueen/
$ cd blackqueen
$ pip install .
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.
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
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
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:
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.
Contributions are welcome. You have an idea, suggestion for improvement or have found a bug? Just create an issue or send a pull request.
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.