DCTL: Draughts and Checkers Template Library
This library is currently in a pre-alpha stage. All code is subject to change without prior notice.
Draughts is a family of related board games played in many regions across the world:
- There are many country-specific game rules such as International/Brazilian/Canadian, American/English, Russian, Italian, Spanish/Portugese, Czech, Thai, and Frisian draughts.
- Draughts is played on checkered boards of dimensions 8x8, 10x10 and 12x12.
- The common game objective is "the first player to have no moves left, loses". A less common variation is so-called misère play ("first to have no moves left, wins"), also known as "suicide", "giveaway", or "qui-perd-gagné".
Many draughts variants have an official governing body, such as the Fédération Mondiale du Jeu de Dames (FMJD, World Draughts Federation).
The DCTL supports all above mentioned draughts variants with official rules, on all board sizes up to 18x18. Most existing draughts variants have a high percentage of draws when played between experienced players. Historically, many small tweaks to the game rules have been proposed. Even former world champions such as Herman Hoogland proposed new variants. The DCTL supports some of these variants. In particular, the recently proposed Killer Draughts is actively supported.
The DCTL provides a series of C++ templates to define the board geometry and game rules of draughts variants. With these templates, one can read and write draughts positions from so-called FEN strings using Portable Draughts Notation. Once a position variable has been initialized with such a FEN string, the DCTL provides further templates to analyze them using a search algorithm, which is supported by a typical board game engine infrastructure of e.g. a move generator, evaluation function and hash table.
Consult the test-suite sources (under the
dctl/testdirectory) for concrete usage examples.
The DCTL does not yet provide a fully functioning game engine that can be plugged into a GUI. It is currently not possible to play a game against a program based on the DCTL. Functionality being planned includes:
- a generic engine class template
- support for the Checkerboard GUI
- support for the GUIDE protocol
- support for the DamExchange protocol
- endgame database generation
These header-only libraries are continuously being tested with the following conforming C++17 compilers:
|6.0, 7, 8, 9-SVN
Note that we are currently awaiting AppVeyor support for Visual Studio 15.9 Preview 3, which should fully support building the DCTL test suite.
The DCTL uses several of the popular Boost C++ libraries. Current development takes place with Boost 1.68.0. Boost is a collection of header-only libraries, and you simply have to point your compiler to the Boost include directory. Consult the Boost documentation on how to do this on your system. After that, you can continue to use your regular build process.
dctl and the accompanying
bit_set repositories to a directory of your choice:
cd ~/projects/ git clone https://github.com/rhalbersma/dctl.git git clone https://github.com/rhalbersma/xstd.git git clone https://github.com/rhalbersma/bit_set.git
To make sure that your build environment is compatible with the DCTL requirements, the DCTL comes with an extensive suite of unit tests, placed in the
dctl/test sub-directory. To build and run the test-suite, follow the requirements (in particular: compile Boost.Test), and from inside the directory in which you downloaded the DCTL, type (where
-jN builds on
N cores in parallel)
mkdir build && cd build cmake .. cmake --build . -- -jN ctest -E "search|traversal"
The build will take less than a minute on a 3.5 GHz Intel i7 (and longer for systems with less parallelism). The test-suite itself takes a second to run. Note that the
ctest command excludes all unit tests that do a tree search or traversal (these tests will take several minutes to hours to run, respectively). If you do not see any errors, the tests succeeded. Congratulations: your system supports the DCTL, and you are now ready to start coding!
Your application is completely independent of the test-suite. Building and running the test-suite is a sufficient but not a necessary step in order to use the DCTL headers with your own application.
Build your application
The DCTL is header-only, which means that you do not have to link your application against a separately compiled library. Furthermore, even though the DCTL is dependent on Boost, you do not have to separately compile Boost yourself, or even
#include any Boost headers. Simply point your compiler to the location of both the DCTL and the Boost headers,
#include the appropriate DCTL header files into your application, and then continue to use your regular build process.
Any feature requests, ideas and contributions are much appreciated! The recommended way to contribute code is through GitHub pull requests.
Special thanks to Aart Bik, Ed Gilbert, Fabien Letouzey, Walter Thoen and Wieger Wesselink for encouragement, testing, and exchange of ideas.