GithubHelp home page GithubHelp logo

arzano / blackqueen Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 1.05 MB

A self learning Loosing-Chess engine using supervised and reinforcement learning

License: Other

Python 100.00%
chess reinforcement-learning supervised-learning neural-network ai loosing-chess antichess

blackqueen's Introduction

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.

blackqueen's People

Contributors

arzano avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.