Skip to content

QueensGambit/CrazyAra

Repository files navigation

Build Status Variants Status License: GPL v3   Codacy Badge ICAPS Badge Journal Badge Thesis Badge ArXiv Badge2 ArXiv Badge

Contents

Description

CrazyAra is an open-source neural network chess variant engine, initially developed in pure python by Johannes Czech, Moritz Willig and Alena Beyer in 2018. It started as a semester project at the TU Darmstadt with the goal to train a neural network to play the chess variant crazyhouse via supervised learning on human data. The project was part of the course "Deep Learning: Architectures & Methods" held by Kristian Kersting, Johannes Fürnkranz et al. in summer 2018.

The development was continued and the engine ported to C++ by Johannes Czech. In the course of a master thesis supervised by Karl Stelzner and Kristian Kersting, the engine learned crazyhouse in a reinforcement learning setting and was trained on other chess variants including chess960, King of the Hill and Three-Check.

The project is mainly inspired by the techniques described in the Alpha-(Go)-Zero papers by David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, Timothy Lillicrap, Karen Simonyan, Demis Hassabis.

The training scripts, preprocessing and neural network definition source files are written in python and located at DeepCrazyhouse/src. There are two version of the search engine available: The initial version is written in python and located at DeepCrazyhouse/src/domain/agent. The newer version is written in C++ and located at engine/src.

CrazyAra is an UCI chess engine and requires a GUI (e.g. Cute Chess, XBoard, WinBoard) for convinient usage.

Links

Download

Binaries

We provide binary releases for the following plattforms:

Operating System Backend Compatible with
Linux CUDA 11.3, cuDNN 8.2.1, TensorRT-8.0.1 NVIDIA GPUs
Linux MXNet 1.8.0, Intel oneAPI MKL 2021.2.0 Intel CPUs
Windows CUDA 11.3, cuDNN 8.2.1, TensorRT-8.0.1 NVIDIA GPUs
Windows MXNet 1.8.0, Intel oneAPI MKL 2021.2.0 Intel CPUs
Mac MXNet 1.8.0, Intel oneAPI MKL 2021.2.0 Mac-Books

The current CrazyAra release and all its previous versions can also be found at releases.

Models

The extracted model should be placed in the directory reltative to the engine executable. The default directory is indicated and can be changed by adjusting the UCI-parameter Model_Directory.

More information about the different models can be found in the wiki.

Artworks

CrazyAra_Hanna_Czech_2023 Drawn by Hanna Czech (2023).

Kristian_and_CrazyAra_2022 Generated with custom stable diffusion model of professor Kristian Kersting.

Variants

Binaries and models are available for the following chess variants:

Documentation

For more details about the initial python version visit the wiki pages:

Compilation

Instructions can be found in the wiki.

Acknowledgments

These libraries are used in the python version:

  • python-chess: A pure Python chess library
  • MXNet: A flexible and efficient library for deep learning
  • numpy: The fundamental package for scientific computing with Python
  • Zarr: An implementation of chunked, compressed, N-dimensional arrays

The following libraries are used to run the C++ version of CrazyAra:

  • Multi Variant Stockfish: Stockfish fork specialized to play chess and some chess variants
    • Used for move generation, board representation and syzgy parsing as a replacement for python-chess.
  • MXNet C++ Package: A flexible and efficient library for deep learning
    • Used as the deep learning backend for loading and inference of the trained neural network
  • TensorRT C++ Package: A C++ library for high performance inference on NVIDIA GPUs and deep learning accelerators
    • Used as the deep learning backend for loading and inference of the trained neural network
  • Blaze: An open-source, high-performance C++ math library for dense and sparse arithmetic
    • Used for arithmetic, numerical vector operation within the MCTS search as a replacement for NumPy
  • Catch2: A multi-paradigm test framework for C++

When CrazyAra is also built with reinforcement learning functionality the following libraries are used:

  • z5: Lighweight C++ and Python interface for datasets in zarr and N5 format
    • Used for exporting generated self-play data in C++ in the Zarr data format
  • xtensor: C++ tensors with broadcasting and lazy computing
    • Used as the internal matrix format within z5

Players

CrazyAra's knowledge in the game of crazhyouse for supervised neural networks is based on human played games of the lichess.org database.

The most active players which influenced the play-style of CrazyAra the most are:

  1. mathace
  2. ciw
  3. retardedplatypus123
  4. xuanet
  5. dovijanic
  6. KyleLegion
  7. LM JannLee
  8. crosky
  9. mariorton
  10. IM opperwezen

Please have a look at Supervised training or our paper for more detailed information.

Related

Similar open source neural network chess projects are listed here.

Research

The following list is a collection of useful research links.

Licence

CrazyAra is free software, and distributed under the terms of the GNU General Public License version 3 (GPL v3). The source-code including all project files is licensed under the GPLv3-License if not stated otherwise.

For details about the GPL v3 license, refer to the file LICENSE.

Publications

  • J. Czech, P. Korus, and K. Kersting: Improving AlphaZero Using Monte-Carlo Graph Search, link
@inproceedings{czech2021icaps_mcgs,
               title={Improving AlphaZero Using Monte-Carlo Graph Search},
	       volume={31},
	       url={https://ojs.aaai.org/index.php/ICAPS/article/view/15952},
	       number={1},
	       journal={Proceedings of the International Conference on Automated Planning and Scheduling},
	       author={Czech, Johannes and Korus, Patrick and Kersting, Kristian},
	       year={2021},
	       month={May},
	       pages={103-111}
	       }
  • J. Czech, M. Willig, A. Beyer, K. Kersting and J. Fürnkranz: Learning to play the Chess Variant Crazyhouse above World Champion Level with Deep Neural Networks and Human Data, link
@ARTICLE{10.3389/frai.2020.00024,
	 AUTHOR={Czech, Johannes and Willig, Moritz and Beyer, Alena and Kersting, Kristian and Fürnkranz, Johannes},   
	 TITLE={Learning to Play the Chess Variant Crazyhouse Above World Champion Level With Deep Neural Networks and Human Data},      
	 JOURNAL={Frontiers in Artificial Intelligence},      
	 VOLUME={3},
	 PAGES={24},
	 YEAR={2020},
	 URL={https://www.frontiersin.org/article/10.3389/frai.2020.00024},       
	 DOI={10.3389/frai.2020.00024},      
	 ISSN={2624-8212}
	 }

M.Sc. Thesis

  • M. Gehrke: Assessing Popular Chess Variants Using Deep Reinforcement Learning, pdf
@mastersthesis{gehrke2021assessing,
	       title = { Assessing Popular Chess Variants Using Deep Reinforcement Learning },
	       author = { Maximilian Alexander Gehrke },
               year = { 2021 },
               type = { M.Sc. },
	       crossref = { https://github.com/QueensGambit/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 94 },
	       month = { jul }
	       }
  • J. Czech: Deep Reinforcement Learning for Crazyhouse, pdf
@mastersthesis{czech2019deep,
	       title = { Deep Reinforcement Learning for Crazyhouse },
	       author = { Johannes Czech },
               year = { 2019 },
               type = { M.Sc. },
	       crossref = { https://github.com/QueensGambit/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 54 },
	       month = { dec }
	       }

B.Sc. Thesis

  • T. Truong: Monte Carlo Tree Search-Minimax Hybrid in AlphaZero, pdf
@bachelorthesis{truong2023monte,
	       title = { Monte Carlo Tree Search-Minimax Hybrid in AlphaZero },
	       author = { Tam Truong },
               year = { 2023 },
               type = { B.Sc. },
	       crossref = { https://github.com/tam201197/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 48 },
	       month = { september }
	       }
  • M. Ruzicka: Utilizing Variance and Uncertainty in Monte-Carlo Tree Search, pdf
@bachelorthesis{ruzicka2023utilizing,
	       title = { Utilizing Variance and Uncertainty in Monte-Carlo Tree Search },
	       author = { Martin Ruzicka },
               year = { 2023 },
               type = { B.Sc. },
	       crossref = { https://github.com/MartinRuz/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 40 },
	       month = { april }
	       }
  • M. Reuter: Nutzung der Neuartigkeit von Zuständen in Suchgraphen von AlphaZero, (German) pdf
@bachelorthesis{reuter2023nutzung,
	       title = { Stochastic Exploration in Minimax Search by Using a Policy Predictor Network },
	       author = { Markus Reuter },
               year = { 2023 },
               type = { B.Sc. },
	       crossref = { https://github.com/KingEsel1/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 58 },
	       month = { march }
	       }
  • J. Holmer: Stochastic Exploration in Minimax Search by Using a Policy Predictor Network, pdf
@bachelorthesis{holmer2022eval,
	       title = { Stochastic Exploration in Minimax Search by Using a Policy Predictor Network },
	       author = { Jannik Holmer },
               year = { 2022 },
               type = { B.Sc. },
	       crossref = { https://github.com/QueensGambit/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 49 },
	       month = { may }
	       }
  • M. Langer: Evaluation of Monte-Carlo Tree Search for Xiangqi, pdf
@bachelorthesis{langer2021eval,
	       title = { Evaluation of Monte-Carlo Tree Search for Xiangqi },
	       author = { Maximilian Langer },
               year = { 2021 },
               type = { B.Sc. },
	       crossref = { https://github.com/QueensGambit/CrazyAra },
	       school = { TU Darmstadt },
	       pages = { 45 },
	       month = { apr }
	       }