Giter Club home page Giter Club logo

spacedog's Introduction

SpaceDog

Chess engine based on VICE, written in C.

Added features include an enhanced evaluation function, PV search, a variety of game recording and logging functions, and Syzygy tablebase support.

This is a learning experience for me, so please watch out for bugs! My main goal is to endow SpaceDog with all the main features we expect from a modern alpha-beta engine, taking inspiration from open-source titans like Stockfish, Crafty, etc., to whom I owe a great debt for inspiring and educating me. As time goes on I'll keep adding my own unique wrinkles.

My ultimate goal for SpaceDog isn't to compete with the big engines, but to make a strong and useful chess partner for myself, and hopefully for other people learning the game. With that in mind I've spent some effort adding game recording and logging functions that I find helpful for learning from my games with SpaceDog, and I'm working on some useful analysis functions too.

Eventually I hope to branch out and add support for neural network evaluations, and support for my favourite chess variants.

Documentation

The Basics

SpaceDog is a UCI/XBoard chess engine, meaning that you will need a chess GUI like Arena or similar to get the best use out of it. You can also run SpaceDog directly on the command line in console mode, and enter your moves manually in long algebraic notation. The easiest way to use SpaceDog is to import it into your favourite UCI chess GUI and use the command line options below to let the GUI start SpaceDog directly in UCI mode with reasonable settings.

Command Line Options

When running SpaceDog, you can use four different command line options to start the engine immediately in console, UCI or XBoard mode with key parameters already set:

  • -h [hash size in MB]: set the size of the hash file (in megabytes)
  • -b [book name]: set the opening book to the given file and initialise it
  • -s [path to Syzygy bases]: set the Syzygy tablebase path and initialise the tablebases
  • -m [uci/xboard/console]: start SpaceDog directly in UCI, XBoard or console mode

So, for example, typing SpaceDog.exe -h 256 -b bookfish.bin -s syzygy -m uci will set the hash to 256MB, load the opening book 'bookfish.bin', initialise tablebases in the folder 'syzygy', and then jump straight into UCI mode. If you don't specify a mode, or start SpaceDog without any arguments, it will go to the main menu of previous releases with the default 64MB hash and opening book. Please make sure the -m argument is used last, otherwise the hash setting might not work correctly.

Note: If you only use the 'mode' command-line switch without the hash size option, UCI/XBoard mode will start without initialising the hash, so please do so with the appropriate UCI/XBoard/console commands.

Other Command Line Options

SpaceDog can use opening books in Polyglot format (.bin file extension). You can choose your opening book options when you start SpaceDog from the command line as follows:

  • Type [executable name] NoBook to turn off the opening book completely
  • Type [executable name] BookName [opening book filename] to read a Polyglot opening book of your choosing
  • Starting SpaceDog without either option will load the default opening book, bookfish.bin, which is available on the Releases tab

If bookfish.bin is not found, or if your chosen opening book is in the wrong format, SpaceDog will start without an opening book.

Choosing a Play Mode

When SpaceDog starts, you have three options for how to play against the engine:

  • Type dog to play in console mode
  • Type xboard to start XBoard mode
  • Type uci to start UCI mode

In console mode, type help to get a list of commands. Most are pretty self-explanatory, but some of the more complex ones are explained below.

Using Syzygy Tablebases

SpaceDog can use Syzygy endgame tablebases thanks to the Fathom API. They can be turned on by using the following commands:

  • Console mode: command syzygypath PATH sets the path to your tablebase files, command usetb will turn on tablebase support and initialise them (the default path is syzygy/ within SpaceDog's folder)
  • XBoard: command egtpath syzygy PATH will activate the tablebases and find them and initialise them at the given path
  • UCI: command setoption name SyzygyPath value PATH will activate the tablebases and find them at the given path

The tablebases will provide SpaceDog with perfect play when she enters an endgame that's in the tablebases. She also uses the WDL tables to guide her search during the midgame toward favourable endgame positions. SpaceDog reports any tablebase hits as tbhits in the search output.

Producing TeX Game Records

SpaceDog can produce full records of your games in console mode in LaTeX format. These files use the skak, xskak and chessboard packages to produce useful diagrams of every position in the game. The intention is to provide useful outputs that a chess learner (like me) can more easily study to find flaws in their play against the engine.

At the moment there are two main TeX game recording functions: one produces a file with large diagrams, two per page, and includes a FEN string under each position to enable analysis in other programs. The other which I call a 'summary', although it isn't really, provides a complete PGN-format record of the game at the start, followed by small diagrams of every half-move with the current move highlighted for easy visibility.

To make use of these, at the start of your game in console mode, enter the command newtex to create a large-diagram game record, or startsum to start the summary format file. You can do both if you like, they're saved in separate files. Once the game reaches a conclusion, enter endtex to close the large-diagram record, or endsum to close the summary file. Once that's done the files can be quickly rendered using any LaTeX distribution that includes the packages skak, xskak, and chessboard.

NB: These functions assume you won't be taking back moves, otherwise things will get weird :) I can probably address this shortcoming by using skak or xskak variations, so keep an eye out for that. Also I need to make some changes to the way checkmates, draws and stalemates are checked, as at the moment it's awkward to pass these results to the TeX records and sometimes the 50-move rule doesn't trigger correctly. Note also that these functions are intended to record complete games, so please start the files before the first move!


Tablebase support is made possible with the Fathom API, based on Ronald de Man's original Syzygy TB probing code and subsequently modified by Basil and Jon Dart. All the code is provided under permissive licenses - Ronald de Man's original code can be "redistributed and/or modified without restrictions", and Jon Dart and Basil's modifications are released under the MIT License.

spacedog's People

Contributors

thorsilver avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spacedog's Issues

UCI issues

  1. In UCI mode SpaceDog incorrectly reports its version via the "id name" string as "1.0". All releases since v0.97.1 are affected.

  2. In UCI mode when SpaceDog plays Black the eval sign appears to be inverted, i.e it reports its score in centipawns without the minus sign when losing. E.g. it loses a piece and shows a "+3.xx" eval (as translated by the GUI). A sample game:

[Event "SpaceDog 0.97.6 64-bit 40/40"]
[Site "Dual X5670"]
[Date "2019.03.08"]
[Round "1"]
[White "King's Out 0.2.42 64-bit"]
[Black "SpaceDog 0.97.6 64-bit"]
[Result "1-0"]
[ECO "B13"]
[GameDuration "00:36:18"]
[GameEndTime "2019-03-08T23:17:13.298 Eastern Standard Time"]
[GameStartTime "2019-03-08T22:40:54.589 Eastern Standard Time"]
[Opening "Caro-Kann"]
[PlyCount "73"]
[TimeControl "40/1260"]
[Variation "Panov-Botvinnik, Czerniak Variation"]

1. e4 {book} c6 {book} 2. d4 {book} d5 {book} 3. exd5 {book} cxd5 {book}
4. c4 {book} Nf6 {book} 5. Nc3 {book} Nc6 {book} 6. Bg5 {book} Qa5 {book}
7. Bxf6 {+0.79/14 28s} exf6 {+0.22/12 37s} 8. cxd5 {+0.77/14 51s}
Bb4 {+0.11/13 37s} 9. Qd2 {+0.41/13 36s} Bxc3 {+0.03/13 37s}
10. bxc3 {+0.33/15 28s} Qxd5 {+0.04/13 37s} 11. O-O-O {+0.26/14 39s}
Be6 {-0.08/12 37s} 12. c4 {+0.34/14 32s} Qd6 {-0.18/12 37s}
13. d5 {+0.37/14 93s} O-O-O {-0.44/12 37s} 14. Qc3 {+0.35/13 96s}
Qc5 {-0.46/12 37s} 15. dxc6 {+1.69/13 21s} Rxd1+ {-2.77/12 37s}
16. Kxd1 {+1.59/14 50s} b5 {-0.33/11 37s} 17. Nf3 {+2.04/13 27s}
b4 {-0.16/11 37s} 18. Qe3 {+2.31/14 57s} Qa5 {0.00/12 37s}
19. Qb3 {+2.49/13 25s} Rd8+ {+1.05/12 37s} 20. Kc1 {+2.42/13 37s}
g5 {+0.79/12 37s} 21. h4 {+3.01/13 43s} g4 {0.00/13 37s} 22. Ne1 {+2.64/14 60s}
Qe5 {0.00/13 37s} 23. Bd3 {+2.93/14 54s} Kc7 {+0.50/12 37s}
24. Qxb4 {+3.40/13 49s} Rb8 {0.00/13 37s} 25. Qe7+ {+3.58/13 33s}
Kc8 {0.00/11 37s} 26. Qxa7 {+4.18/13 33s} f5 {0.00/11 37s}
27. Nc2 {+4.85/14 37s} Rb2 {+0.49/11 37s} 28. c5 {+7.82/14 30s}
Rb8 {+5.81/13 37s} 29. Qa5 {+11.00/14 30s} Rb2 {+10.80/13 37s}
30. Ba6+ {+13.62/14 27s} Kb8 {+12.45/12 37s} 31. Rd1 {+20.40/14 25s}
Rxc2+ {+299.80/12 37s} 32. Kxc2 {+M14/14 14s} Bb3+ {+299.86/12 37s}
33. Kxb3 {+M10/10 0.45s} Qe6+ {+299.92/13 37s} 34. Ka3 {+M8/4 0.30s}
Qxc6 {+299.92/12 37s} 35. Rb1+ {+M6/4 0.31s} Ka7 {+299.96/12 37s}
36. Bf1+ {+M4/7 0.33s} Qa6 {+299.98/13 37s} 37. Qxa6# {+M2/5 0.31s, White mates}
1-0

Besides looking daft this makes adjudication by GUI impossible.

v0.97.6 eval/pruning issues

v0.97.1 has been tested at CCRL at 40/4 and received a 2088 Elo rating. Another tester ran several hundred games with v0.97.4 for a similar performance (the results will be up after the pending update by Sunday).

A 40/40 test for the latest version, 0.97.6, had to be aborted when SpaceDog scored 0/13 vs. the 2100-rated King's Out. In eight games SpaceDog didn't make it even to the first time control. Thinking there was a problem with the UCI mode I switched to the Xboard mode but SpaceDog continued playing wildly, giving away pieces left and right. Here's a sample blitz game vs. Monik (1955 Elo):

[Event "?"]
[Site "?"]
[Date "2019.03.09"]
[Round "?"]
[White "SpaceDog 0.97.6 64-bit"]
[Black "Monik 2.2.7 64-bit"]
[Result "0-1"]
[ECO "A82"]
[GameDuration "00:01:52"]
[GameEndTime "2019-03-09T03:43:43.701 Eastern Standard Time"]
[GameStartTime "2019-03-09T03:41:50.922 Eastern Standard Time"]
[Opening "Dutch"]
[PlyCount "45"]
[Termination "adjudication"]
[TimeControl "40/120"]
[Variation "Staunton gambit"]

1. d4 {book} f5 {book} 2. e4 {book} fxe4 {book} 3. Nc3 {book} Nf6 {book}
4. f3 {book} exf3 {book} 5. Nxf3 {book} d5 {book} 6. Bd3 {book} g6 {book}
7. Bf4 {+0.12/9 3.5s} e6 {-0.02/8 3.8s} 8. O-O {-0.13/8 3.5s} Bd6 {-0.02/8 3.7s}
9. Bh6 {-0.21/9 3.5s} Rg8 {+0.04/8 3.7s} 10. Nb5 {0.00/9 3.5s}
Nc6 {+0.02/7 3.7s} 11. Ng5 {+0.94/11 3.5s} Be7 {-0.27/7 3.7s}
12. Nxh7 {+0.95/11 3.5s} Nxh7 {-0.03/8 3.7s} 13. Qg4 {+1.01/11 3.5s}
Nf6 {+1.89/8 3.7s} 14. Bxg6+ {+0.91/11 3.5s} Kd7 {+2.95/9 3.7s}
15. Qxe6+ {0.00/12 3.5s} Kxe6 {+8.81/3 0.19s} 16. Bg7 {0.00/12 3.5s}
Rxg7 {+11.72/10 3.8s} 17. Rae1+ {-7.19/13 3.5s} Kd7 {+11.72/10 3.8s}
18. Rxf6 {-7.19/12 3.5s} Nxd4 {+13.47/9 3.8s} 19. Nxd4 {-9.06/12 3.5s}
Bxf6 {+13.74/9 3.8s} 20. Bf5+ {-11.71/12 3.5s} Kd6 {+13.54/3 0.21s}
21. Nb5+ {-12.81/12 3.5s} Kc5 {+15.25/9 3.9s} 22. b4+ {-12.68/10 3.5s}
Kxb5 {+18.50/9 3.9s} 23. Bd3+ {-16.67/11 3.5s, Black wins by adjudication} 0-1

Note that on move 15 SpaceDog, already a piece down, gives up the queen for the e6-pawn and a few checks. A 2088-rated engine wouldn't play like that. Clearly, some changes since v0.97.4 cost SpaceDog hundreds Elo points.

Tirsa@CCRL

Xboard issues

In response to the "xboard" command SpaceDog sends its "feature" list. This behavior is incorrect; the feature list should be sent in response to the "protover"/"protover 2" command.

A direct consequence of this nonstandard behavior is that under Cute Chess GUI SpaceDog can only play with the default hash (~64 MB) as the GUI doesn't register the "feature memory=1" command. In fact it misses the entire section of the feature list before "feature egt", viz:

<SpaceDog 0.97.6 64-bit(54): HashTable init complete with 2796200 entries
<SpaceDog 0.97.6 64-bit(54): Using default opening book: BookFish!
<SpaceDog 0.97.6 64-bit(54): Book File Not Read
<SpaceDog 0.97.6 64-bit(54): Welcome to SpaceDog! Type 'dog' to play in console mode. 
<SpaceDog 0.97.6 64-bit(54): SpaceDog > feature ping=1 setboard=1 colors=0 usermove=1 memory=1
<SpaceDog 0.97.6 64-bit(54): feature egt="syzygy"
>SpaceDog 0.97.6 64-bit(54): accepted egt
<SpaceDog 0.97.6 64-bit(54): feature done=1
>SpaceDog 0.97.6 64-bit(54): accepted done
>SpaceDog 0.97.6 64-bit(54): egtpath syzygy e:\345
>SpaceDog 0.97.6 64-bit(54): new
>SpaceDog 0.97.6 64-bit(54): force
>SpaceDog 0.97.6 64-bit(54): level 40 21 0
>SpaceDog 0.97.6 64-bit(54): post
>SpaceDog 0.97.6 64-bit(54): easy
<SpaceDog 0.97.6 64-bit(54): command seen:rotover 2
<SpaceDog 0.97.6 64-bit(54): command seen:accepted egt
<SpaceDog 0.97.6 64-bit(54): command seen:accepted done
<SpaceDog 0.97.6 64-bit(54): command seen:egtpath syzygy e:\345
<SpaceDog 0.97.6 64-bit(54): Using TB file path: e:\345
<SpaceDog 0.97.6 64-bit(54): Using Syzygy tablebases for 5 pieces or less!
<SpaceDog 0.97.6 64-bit(54): command seen:new
<SpaceDog 0.97.6 64-bit(54): command seen:force
<SpaceDog 0.97.6 64-bit(54): command seen:level 40 21 0
<SpaceDog 0.97.6 64-bit(54): DEBUG level without :
<SpaceDog 0.97.6 64-bit(54): DEBUG level timeLeft:1260000 movesToGo:40 inc:0 mps40
<SpaceDog 0.97.6 64-bit(54): command seen:post
<SpaceDog 0.97.6 64-bit(54): command seen:easy

Note the "command seen:rotover 2" line, SpaceDog doesn't manage to parse the GUI's commands properly.

CECP v2 specs: http://home.hccnet.nl/h.g.muller/engine-intf.html

v0.97.5.1 issues

This version is a big improvement over the ill-fated v0.97.6; some issues still remain.

  1. It seems that you misunderstood me in #16. The polarity of SpaceDog's eval is still wrong when it plays Black. This affects both the Winboard and the UCI mode. It shows the absolute (i.e. from White's POV) eval whereas the CECP and the UCI specs require the eval be relative to the engine itself. So regardless of which color it plays if an engine is winning its eval should be a positive cp value; if it's losing then the eval needs the minus sign.

For Winboard engines there's an option to treat the engine's eval as absolute and I took advantage of that when running the 40/40 gauntlet. However

  1. the Winboard mode still doesn't function properly under Cute Chess. When the engine is initialized it appears that it misses the "xboard" from the GUI altogether and the first letter of "protover". So none of the feature options are initialized -- no Syzygy support or configurable hashtable.

Using the InBetween adapter I was able to record what happens between the engine and the GUI:

0.000: - Starting server: SpaceDog_TBs-09751.exe nobook
0.016: - Priority class set to normal
0.016: - Thread priority set to normal
0.016: > xboard
0.016: > protover 2
0.032: < HashTable init complete with 2796200 entries
0.032: < Book File Not Read
0.032: < 
0.032: < Welcome to SpaceDog! Type 'dog' to play in console mode. 
0.032: < 
0.032: < SpaceDog > command seen:rotover 2
0.032: < 
8.003: > new
8.003: < command seen:new
8.003: > force

This does not occur when entering the commands manually in the console, so I suspect that SpaceDog is too slow to react to the GUI's commands on the startup as it's busy initializing the hashtable and printing its own stuff which may be blocking its I/O.

I managed to circumvent the issue by having InBetween issue a blank line followed by an extra "xboard" command after that of the GUI, so in effect SpaceDog receives this:

xboard

xboard
protover 2

everything goes as expected then. That's how the above-mentioned gauntlet was run; it's now complete and SpaceDog is on the 40/40 list. I expect you might be as surprised by its results as I was. :)

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.