Scorpio chess engine
Clone or download
Latest commit f6dc98a Jan 16, 2019

Readme.md

Table of Contents

  1. Scorpio
  2. Goals
  3. Parallel
  4. MCTS
  5. Neural Networks
  6. EGBB
  7. Acknowledgement
  8. Book

Scorpio

Scorpio is a strong chess engine at the grand master level. It can be used with GUIs that support the Winboard protocol natively such as Winboard and Arena, or via the Wb2Uci adapter in Fritz and Shredder interfaces.

Goals

The main goals of Scorpio are:

  • Parallel : Experiments with parallel search algorithms such as YBW and ABDADA algorithms both on shared memory (SMP) and non-uniform memory access (NUMA) systems. Also distributed parallel search on a loosely coupled cluster of computers is done using YBW.

  • MCTS : Experiments with montecarlo tree search (MCTS) for chess. It supports alpha-beta rollouts with LMR and null move in the tree part of the search, coupled with standard MCTS rollouts or standard alpha-beta search.

  • Neural Networks : Experiments with neural network evaluation ala AlaphaZero.

  • EGBB : Experiments with encoding, compression and use of endgame bitbases (EGBBS) of upto 6 pieces

Parallel

Cluster version of scorpio can be compiled with MPI libraries OpenMPI or MPICH. Work is distributed using YBW algorithm. To run Scorpio on cluster start one processor per node using "mpirun -pernode" and set "mt" option to "auto" in scorpio.ini so that it detects number of pro- cessors automatically. You can also start processes only but it will run slower. Experiment with split depth parameters for optimal perfor- mance.

  • CLUSTER_SPLIT_DEPTH (default 8)
  • SMP_SPLIT_DEPTH (default 4)

MCTS

The montecarlo tree search engine uses alpha-beta rollouts according to Huang paper. This is much stronger than standard MCTS in games like chess which ar full of tactics. ScorpioMCTS storing all the tree in memory has become very close in strength to the standard alpha-beta searcher due to alpha-beta rollouts. It can actually become same strength as the standard if we limit the amount of tree stored in memory via "treeht" parameter in the scorpio.in. When the MCTS search runs out memory, it will spawn standard recursive alpha-beta search at the leaves so setting treeht = 0 stores only root node and its children, effectively becoming same strength as the standard alpha-beta method. If we set treeht = 128 MB, upper parts of the tree will be stored in memory and MCTS used there. Note that 128MB of memory are not allocated immediately at start up; it only specifies the maximum memory to use for storing tree. Don't forget to set montecarlo=1 if you want to experiment with MCTS.

  • montecarlo 1
  • treeht 128

The parallel search for MCTS uses virtual loss to distribute work among threads in standard MCTS rollouts, and ABDADA like BUSY flag for alpha-beta rollouts. ABDADA and parallel MCTS from the Go world are very similar in nature.

Neural Networks (NNs)

The neural network version of Scorpio works using egbbdll that provides neural network inference via tensorflow and/or TensorRT backends.

Building egbbdll

The egbbdll serves dual purpose, namely, for probing bitbases and neural networks. If you just want the former, the build processess is very easy.

First clone the repository

git clone https://github.com/dshawul/egbbdll.git
Building without neural network support

Then set the following variables to 0 in the Makefile

USE_TF = 0
USE_TRT = 0

Then

make

That is it.

Building with neural network support

To build egbbdll with neural network support is a lot more complicated. Neural network inference is done via tensorflow and/or TensorRT backends. This means you are limited to NVIDIA GPUs atleast until OpenCL support is complete in these libraries.

Downloading binaries (for Windows)

The easiest way on a Windows machines is to download the binaries I provide for both CPU and GPU (with CUDA + cuDNN libraries). Here are the links for convenience

egbbdll64-nn-windows-cpu.zip

egbbdll64-nn-windows-gpu.zip

Extract it in a directory where bitbases are located so it can serve its dual purpose. For the GPU version of egbbdll, we need to set the Path environment variable ( in the case of linux the LD_LIBRARY_PATH variable) so that the system can find cudnn.dll, nvinfer.dll and other dependencies.

Building from sources (for linux)

For those who feel adventurous, here is how you build from sources. Egbbdll needs tensorflow for neural network inference on the CPU, however, on the GPU there is another option that is less complicated to build AND also significantly faster. That option is using TensorRT and UFF format network files. We need to install the followind dependencies for the TensorRT backend:

* cuDNN
* CUDA
* TensorRT

These can be download NVIDA developer page Make sure you download compatible versions (e.g. cuDNN 7.3 + CUDA 10.0 + TensorRT 5.0)

Building egbbdll with TensorRT backend

Clone the egbbdll repository

git clone https://github.com/dshawul/egbbdll.git

Then go into the Makefile and set the paths to the dependencies

#########################################
#  USE_TF      0 = Don't use tensorflow
#              1 = tensorlow_cc
#              2 = manually built tensorflow
#  USE_TRT     0 = Don't use TensorRT
#              1 = Use TensorRT
#  USE_SHARED  0 = static linking if possible
#              1 = dynamic linking to TF/TRT
########################################
USE_TF = 0
USE_TRT = 1
USE_SHARED = 1

########################################
# Set directories to dependenies
########################################

ifeq ($(USE_TF),1)
    TF_DIR=/usr/local
else ifeq ($(USE_TF),2)
    TF_DIR=/home/daniel/tensorflow
endif

ifneq ($(USE_TRT),0)
    TRT_DIR = /home/daniel/TensorRT-5.0.0.10
    CUDA_DIR = /usr/local/cuda
endif

Then build egbbso64.so with

make

That is it.

Building egbbdll with tensorflow backend

To build egbbdll with libtensorflow_cc.so dependency, do one of the following.

Option 1 - using tensorflow_cc on linux only

The first option is to use tensorflow_cc (USE_TF = 1). Build the C++ tensorflow library following the steps given here.

It may be easier to use docker using the command below instead of building the shared library with bazel yourself.

docker run --runtime=nvidia -it floopcz/tensorflow_cc:ubuntu-shared-cuda /bin/bash

Once the build and install (or docker load) is complete, you should see the tensorflow and protobuf libraries

$ ls /usr/local/lib/tensorflow_cc/
libprotobuf.a  libtensorflow_cc.so
Option 2 - manually building tensorflow

The second option is to build tensorflow manually without using scripts (USE_TF = 2). This option also works on windows. Go into the tensorflow director and execute

bazel build --config=opt --config=monolithic //tensorflow:libtensorflow_cc.so

This will take hours to build so be patient. Once it completes, you will find the library in bazel-bin/tensorflow directory.

Build egbbdll directly using bazel -- i.e. without using Makefile

To compile egbbdll directly using bazel, put the egbbdll source directory in tensorflow/tenorflow/cc/ and then compile with

bazel build --config=opt --config=monolithic //tensorflow/cc/egbbdll:egbbdll64.dll

You will then find the egbbdll64.dll in bazel-bin/tensorflow/cc/egbbdll directory. This option currently doesn't work with the TensorRT backend.

Building Scorpio

This is very straightforward:

git clone https://github.com/dshawul/Scorpio.git
cd Scorpio && make && cd ..

This will get you a linux scorpio executable.

Testing on the CPU

$ ./scorpio use_nn 1 mt 2 montecarlo 1 frac_alphabeta 0 backup_type 6 book off go quit
feature done=0
ht 4194304 X 16 = 64.0 MB
eht 524288 X 8 = 8.0 MB
pht 32768 X 24 = 0.8 MB
treeht 335539200 X 40 = 12799.8 MB
processors [1]
processors [2]
EgbbProbe 4.1 by Daniel Shawul
180 egbbs loaded !      
Loading neural network ...
Neural network loaded ! 
loading_time = 0s
[st = 11114ms, mt = 29250ms , hply = 0 , moves_left 10]
63 14 111 7849  d2-d4 d7-d5 Nb1-c3
64 22 222 17438  e2-e4 Ng8-f6 d2-d3 d7-d5 Nb1-c3
65 24 334 28334  d2-d4 d7-d5 c2-c4 e7-e6
66 24 445 43483  d2-d4 e7-e5 e2-e3 d7-d6 Ng1-f3
67 23 556 61266  d2-d4 e7-e5 e2-e3 d7-d6 d4xe5 d6xe5 Qd1xd8 Ke8xd8
68 21 668 84004  e2-e4 Ng8-f6 f2-f3 e7-e5 d2-d3 Nb8-c6 Nb1-c3
69 20 779 112214  e2-e4 Ng8-f6 d2-d3 d7-d6 Nb1-c3 e7-e5
70 19 890 151678  e2-e4 e7-e5 d2-d3 d7-d6 Nb1-c3 Ng8-f6 Bc1-e3 Nb8-c6
71 18 1002 195211  e2-e4 e7-e5 d2-d4 e5xd4 Qd1xd4 Nb8-c6 Qd4-d1 d7-d6 Ng1-f3 Bc8-e6 Bc1-e3 Ng8-f6 Nb1-c3 a7-a6 h2-h3 h7-h6 Bf1-d3 g7-g6 a2-a3 Bf8-g7 Ke1-g1

#  1     10    1151 e2-e4 e7-e5 d2-d4 e5xd4 Qd1xd4 Nb8-c6 Qd4-d1 d7-d6 Ng1-f3 Bc8-e6 Bc1-e3 Ng8-f6 Nb1-c3 a7-a6 h2-h3 h7-h6 Bf1-d3 g7-g6 a2-a3 Bf8-g7 Ke1-g1 Ke8-g8 Qd1-e2 Qd8-e7 Rf1-d1 Nf6-d7 Bd3-c4 f7-f5 Nc3-d5 Qe7-f7 e4xf5 Qf7xf5 Be3xh6 Be6xd5 Bc4xd5 Kg8-h7 Bh6xg7 Kh7xg7
#  2      9     710 d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 e7-e6 Bf1-d3 Bf8-d6 Nb1-d2 Nb8-c6 Ke1-g1 Ke8-g8
#  3      7     224 Nb1-c3 e7-e5 e2-e4 d7-d6 f2-f3 Nb8-c6 d2-d3 Bc8-e6 Bc1-e3
#  4      8     516 Ng1-f3 d7-d5 d2-d4 Ng8-f6 g2-g3 Bc8-d7 Nb1-c3 Nb8-c6 Bf1-g2 e7-e6 Ke1-g1 a7-a6 Bc1-e3 h7-h6 a2-a3
#  5      6     149 e2-e3 e7-e5 Ng1-f3 d7-d6 Nb1-c3 Ng8-f6 Bf1-b5
#  6      8     267 d2-d3 d7-d5 c2-c4 e7-e6 Ng1-f3 Nb8-c6 c4xd5 e6xd5 e2-e4 Ng8-f6
#  7      4     101 g2-g3 e7-e5 e2-e4 d7-d6 d2-d3 Nb8-c6
#  8      2      76 b2-b3 d7-d5 d2-d4 Ng8-f6
#  9      5     129 f2-f3 e7-e5 e2-e4 Bf8-c5 d2-d3 Nb8-c6 Nb1-c3
# 10      2      83 h2-h3 d7-d5 d2-d4 e7-e6 Ng1-f3 Ng8-f6
# 11      3      87 c2-c3 d7-d5 Ng1-f3 e7-e6 d2-d4 Ng8-f6
# 12      0      58 a2-a3 d7-d5 d2-d3 e7-e6 e2-e4
# 13      0      59 Nb1-a3 d7-d5 d2-d4 e7-e6 Ng1-f3
# 14      2      75 Ng1-h3 e7-e5 e2-e4 d7-d6 Nb1-c3 Nb8-c6
# 15      4     107 f2-f4 Ng8-f6 Ng1-f3 d7-d5 d2-d3 Nb8-c6 Nb1-c3
# 16      8     326 c2-c4 e7-e5 d2-d3 d7-d6 Ng1-f3 Ng8-f6 e2-e4 h7-h6 h2-h3 Bc8-e6 Nb1-c3 Nb8-c6 Bc1-e3 a7-a6 a2-a3 g7-g6 Bf1-e2
# 17     -8      35 h2-h4 e7-e5 Nb1-c3 Nb8-c6
# 18     -4      44 a2-a4 d7-d5 d2-d3 Ng8-f6
# 19    -13      27 g2-g4 d7-d5 d2-d4 Ng8-f6
# 20      1      71 b2-b4 e7-e5 Bc1-b2 Bf8xb4 Bb2xe5

nodes = 513255 <93% qnodes> time = 11120ms nps = 46156 eps = 37600 nneps = 329
Tree: nodes = 123105 depth = 38 pps = 384 visits = 4276 
      qsearch_calls = 62618 search_calls = 0
move e2e4
Bye Bye

Testing on the GPU

On the GPU we use multi-threaded batching so launch as many threads as you can. Here is a run of the same problem as the CPU but with 128 threads and a single P100 GPU. You can see that it hits 10000n/s compared to the 384n/s we get on the CPU

$ ./scorpio use_nn 1 mt 128 montecarlo 1 frac_alphabeta 0 backup_type 6 go quit
feature done=0
ht 4194304 X 16 = 64.0 MB
eht 524288 X 8 = 8.0 MB
pht 32768 X 24 = 0.8 MB
treeht 335539200 X 40 = 12799.8 MB
processors [1]
processors [128]
EgbbProbe 4.1 by Daniel Shawul
0 egbbs loaded !      
Loading neural network ...
Neural network loaded ! 
loading_time = 12s
[st = 11114ms, mt = 29250ms , hply = 0 , moves_left 10]
63 35 161 134  e2-e4 e7-e5 Ng1-f3 d7-d6
64 16 272 7147  d2-d4 d7-d5 e2-e4 d5xe4 Nb1-c3 Nb8-c6
65 16 383 17114  d2-d4 d7-d5 Ng1-f3 Ng8-f6 h2-h3 e7-e6 e2-e3
66 16 495 26337  d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 Nb8-c6 Nb1-c3
67 17 607 38323  d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 e7-e6 Bf1-b5 Nb8-c6 Ke1-g1
68 17 719 52523  d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 g7-g6 c2-c4 d5xc4 Bf1xc4
69 17 831 62733  d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 Bc8-e6 Nb1-d2 Nb8-c6 Bf1-d3 h7-h6 Ke1-g1
70 17 943 78135  d2-d4 d7-d5 Ng1-f3 Ng8-f6 b2-b4 Nf6-e4 Bc1-b2 Bc8-e6 b4-b5 Nb8-d7 e2-e3 h7-h6 Nb1-c3
71 17 1057 103815  d2-d4 d7-d5 Ng1-f3 Ng8-f6 e2-e3 g7-g6 c2-c4 Bf8-g7 Nb1-c3 d5xc4 Bf1x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 depth = 53 pps = 10396 visits = 116094 
      qsearch_calls = 26356 search_calls = 0
move d2d4
Bye Bye

Modifying Scorpio.ini for NN use

Once you make sure everything is working you can save the command line options in scorpio.ini so that you just specify ./scorpio next time. For something that looks like AlphaZero's MCTS+NN search and evaluation use the following options

montecarlo               1
frac_alphabeta           0
backup_type              6
use_nn                   1
nn_path                  nets-ccrl/net-6x64.pb

EGBB

Scorpio uses its own endgame bitbases upto 6 pieces.

Installation

First You have to download some of the bitbases.

Then put them anywhere in your computer and set the egbb_path, egbb_cache_size and egbb_load_type in the scorpio ini file. Suggested cache size for 4 men egbbs is minimum 4 Mb, for 5 piece minimum 16 Mb, and for 6-men as much as you can. Putting the EGBBs on SSD or USB drives can also speed up access time.

For programmers

For those who want to add support to the bitbases, please take a look at the probe.cpp. There are two files egbbdll.dll and egbbso.so that you can use to probe the bitbases in Windows and Linux. These files should be put in the same directory as the egbbs (not anywhere else!). So what you need to do is load these libraries at run time and use their functions. Your engines size hardly increases unlike the case if you used Nalimov's egtbs. Plus the engine don't have to be recompiled when- ever updates for the egbbs are released. If your engine added supprot for the very first version of the egbbdll.dll , which btw is completely different from the current design, can still use the latest available egbbdll.

The 4men bitbases are loaded to RAM by default so they are fast to use. You can also load the 5 men egbb's to RAM but they require too much RAM. So you might prefer to probe them on disk like i do. But make sure that you don't call them near the leaves of the search tree if they are not loaded on RAM.

After egbbdll.dll is loaded and we have to get the address of probe_egbb and load_egbb functions. New functions are provided for 6-men egbbs , probe_egbb_xmen and load_egbb_xmen.

   load_egbb = (PLOAD_EGBB) GetProcAddress(hmod,"load_egbb_xmen");
   probe_egbb = (PPROBE_EGBB) GetProcAddress(hmod,"probe_egbb_xmen");

Then we can call these functions like any other standard functions.

   typedef int (*PLOAD_EGBB) (char* path,int cache_size,int load_options);

Parameters

   path         => it is the directory where the bitbases are located
   cache_size   => size of cache used in bytes
   load_options => options to load some bitbase in to RAM. By default 
                   the 4 men are loaded in to RAM.

Returns

   true => if loading succeeds false otherwise. 

   typedef int (*PPROBE_EGBB) (int player, int* piece, int* square);

Parameters

    player   => side to move
    *piece   => piece types
    *square  => square of pieces (A1=0...H1=7...A8=56...H8...63)

The piece array should be terminated with 0 and the last element of square array should be the enpassant square if it exists or 0 otherwise.

Returns

    0         => draw
    >0        => win
    <0        => loss
   _NOTFOUND  => bitbase is not included

Scores are modified according to many factors.

    score = WIN_SCORE 
	- 10 * distance(SQ6488(w_king),SQ6488(b_king)) 
	+ (5 - all_c) * 1000;

This type of scoring helps in making progress by prefering 3-men endings over 5-men, cornering losing king, handling special endings such as KBNK.

Note

Those who supported the egbbs does not have to use the method scorpio uses for probing. It is upto the programmer to decide what to do with them.

Acknowledgement

Thanks to the following persons for helping me with development of Scorpio: Dann Corbit. Gerhard Schwager, Oliver Deuville, Gunther Simon, Leo Dijksman, Ed Shroeder and Pradu Kanan, Shaun Brewer, Werner Schule, Klaus Friedel, Andrew Fan, Andres Valverde, Bryan Hoffman, Martin Thorensen

Book

Salvo Spitaleri is the book author for scorpio. Thanks also goes to Oliver Deuville for the book which earlier version use.