Unofficial stockfish 28.04.2013 with rtb tablebases support

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

syzygy
Posts: 5697
Joined: Tue Feb 28, 2012 11:56 pm

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by syzygy »

Marek Soszynski wrote:[d]8/5k2/8/8/8/4p2P/5p2/7K b - - 0 74

A simple mate in four, but Stockfish-rtb, with the new tablebases, insists on under-promoting to a knight.
This is how DTZ tables work. It can lead to unnatural play. It attempts to minimize the number of moves to a capture or pawn move (by either side), which means it will prefer a pawn move over a mate in two.

The good thing is that this will never give a problem with the 50-move rule. Another good thing is that this allows the tables to be small.

To fix the unnatural play, the engine needs to be smarter once the game has entered a tablebase position. Instead of playing the move with lowest DTZ value (distance to capture or pawn move), the engine should do a (short) search on the moves that preserve the win and that have a DTZ value well within what's left of the 50-move budget. This avoids trouble with the 50-move rule. In addition, to avoid draw-by-repetition, the engine should detect repetition of an earlier position and if that occurs once, just switch to DTZ-optimal play until a pawn move or capture is reached.
Paloma
Posts: 1206
Joined: Thu Dec 25, 2008 9:07 pm
Full name: Herbert L

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by Paloma »

Is it possible to get a Non-sse4.2 compile? It would be great! :D
Many thanks.
Uri Blass
Posts: 10825
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by Uri Blass »

I read about comstock3.0.0 that include tablebase support in the stockfish developement forum.

I wonder if it is based on Jean-Francois Romang's stockfish or maybe it is a different implementation of tablebases.

I read the following result for comstock3.0.0
+3361-3082=7760 at 10 s +0.1 second per move.
j_romang
Posts: 79
Joined: Mon May 16, 2011 2:52 am

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by j_romang »

My branch is bases on Ronald de Man's tablebases (http://talkchess.com/forum/viewtopic.php?t=47681). Unfortunately the current implementation is not finished and does not take full profit of Ronald's work ! This is just an experimental toy waiting for bug reports :)
Comstock is based on robbobases (http://ippolit.wikispaces.com/RobboBases) ; so yes that's a different implementation
ernest
Posts: 2048
Joined: Wed Mar 08, 2006 8:30 pm

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by ernest »

j_romang wrote:Thanks, corrected and here is the new binary file : https://www.dropbox.com/s/jnouj6jh3fwav ... 42-RTB.zip
:D
Salut Jean-François,
I would like to experiment with RTB, but my old processor is not popcnt/sse4.2 compatible.
If you find the time, could you compile a non popcnt/sse4.2 version (64-bit or 32-bit, as you like).
User avatar
Marek Soszynski
Posts: 586
Joined: Wed May 10, 2006 7:28 pm
Location: Birmingham, England

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by Marek Soszynski »

syzygy wrote:
Marek Soszynski wrote:[d]8/5k2/8/8/8/4p2P/5p2/7K b - - 0 74

A simple mate in four, but Stockfish-rtb, with the new tablebases, insists on under-promoting to a knight.
This is how DTZ tables work. It can lead to unnatural play. It attempts to minimize the number of moves to a capture or pawn move (by either side), which means it will prefer a pawn move over a mate in two.
Of the four moves leading to the quickest checkmate, three are pawn moves.

To be fair, this early Stockfish-rtb is more a proof of concept than a fully practical engine.
Marek Soszynski
syzygy
Posts: 5697
Joined: Tue Feb 28, 2012 11:56 pm

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by syzygy »

Marek Soszynski wrote:To be fair, this early Stockfish-rtb is more a proof of concept than a fully practical engine.
In my private engine I have now implemented a more sophisticated handling of the root position which seems to be working quite nicely. I'll try to port it to Stockfish, but it will take a few days before I have time.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by zamar »

syzygy wrote:
Marek Soszynski wrote:[d]8/5k2/8/8/8/4p2P/5p2/7K b - - 0 74

A simple mate in four, but Stockfish-rtb, with the new tablebases, insists on under-promoting to a knight.
This is how DTZ tables work. It can lead to unnatural play. It attempts to minimize the number of moves to a capture or pawn move (by either side), which means it will prefer a pawn move over a mate in two.

The good thing is that this will never give a problem with the 50-move rule. Another good thing is that this allows the tables to be small.

To fix the unnatural play, the engine needs to be smarter once the game has entered a tablebase position. Instead of playing the move with lowest DTZ value (distance to capture or pawn move), the engine should do a (short) search on the moves that preserve the win and that have a DTZ value well within what's left of the 50-move budget. This avoids trouble with the 50-move rule. In addition, to avoid draw-by-repetition, the engine should detect repetition of an earlier position and if that occurs once, just switch to DTZ-optimal play until a pawn move or capture is reached.
To implement this for Stockfish, one could do following:

- Stockfish maintains a RootMoveList (a list of moves that are searched).
- If we have a tablebase position at root, check which moves preserve the win/draw. Remove other moves from root move list.
- Let the search run as usual.

This would result in "natural" play without ever losing a win/draw. It might not be optimal from time management perspective though.
Joona Kiiski
syzygy
Posts: 5697
Joined: Tue Feb 28, 2012 11:56 pm

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by syzygy »

zamar wrote:
syzygy wrote:
Marek Soszynski wrote:[d]8/5k2/8/8/8/4p2P/5p2/7K b - - 0 74

A simple mate in four, but Stockfish-rtb, with the new tablebases, insists on under-promoting to a knight.
This is how DTZ tables work. It can lead to unnatural play. It attempts to minimize the number of moves to a capture or pawn move (by either side), which means it will prefer a pawn move over a mate in two.

The good thing is that this will never give a problem with the 50-move rule. Another good thing is that this allows the tables to be small.

To fix the unnatural play, the engine needs to be smarter once the game has entered a tablebase position. Instead of playing the move with lowest DTZ value (distance to capture or pawn move), the engine should do a (short) search on the moves that preserve the win and that have a DTZ value well within what's left of the 50-move budget. This avoids trouble with the 50-move rule. In addition, to avoid draw-by-repetition, the engine should detect repetition of an earlier position and if that occurs once, just switch to DTZ-optimal play until a pawn move or capture is reached.
To implement this for Stockfish, one could do following:

- Stockfish maintains a RootMoveList (a list of moves that are searched).
- If we have a tablebase position at root, check which moves preserve the win/draw. Remove other moves from root move list.
- Let the search run as usual.

This would result in "natural" play without ever losing a win/draw. It might not be optimal from time management perspective though.
Yes, this is very much how I do it now in my own engine. I also reduce the allocated time by a factor 5.

One part that is a bit tricky is that the search "as usual" should probably have a cleared hash table (since TB positions are already stored there as "win" or "draw" and we don't want to use that information). In my own engine I implement this by xor'ing the hash key of the root position with a random value before and after the search. I suppose this will work for Stockfish as well.

In the position given above, my engine would now play 1..f1=Q+ 2.Kh2 Qf2+ 3.Kh1 e2 4.h4 e1=Q# and not anymore (for example) 1...f1=Q+ 2.Kh2 Qxh3+ 3.Kxh3 e2 :-)
Vinvin
Posts: 5290
Joined: Thu Mar 09, 2006 9:40 am
Full name: Vincent Lejeune

Re: Unofficial stockfish 28.04.2013 with rtb tablebases supp

Post by Vinvin »

zamar wrote: ...
To implement this for Stockfish, one could do following:

- Stockfish maintains a RootMoveList (a list of moves that are searched).
- If we have a tablebase position at root, check which moves preserve the win/draw. Remove other moves from root move list.
- Let the search run as usual.

This would result in "natural" play without ever losing a win/draw. It might not be optimal from time management perspective though.
As a generalization : each time it's SF side to move only select best moves (win or draw) from TB and add +20 to score if winning (and divide by 20 when it's draw). This not only on root ...