Stockfish: Racing kings draw condition

Created on 28 Mar 2017  路  8Comments  路  Source: ddugovic/Stockfish

Stockfish incorrectly believes the position is mate in 1 and throws away the win. I believe racing kings draws were working in an earlier version.

Stockfish 280317 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
setoption name uci_variant value racingkings
position fen 8/k5K1/1r4Q1/2n2R2/8/8/6B1/8 w - - 4 16
d 

 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 | k |   |   |   |   |   | K |   |
 +---+---+---+---+---+---+---+---+
 |   | r |   |   |   |   | Q |   |
 +---+---+---+---+---+---+---+---+
 |   |   | n |   |   | R |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   | B |   |
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+

Fen: 8/k5K1/1r4Q1/2n2R2/8/8/6B1/8 w - - 4 16
Key: 3CA87CC09922DEF8
Checkers: 
go depth 20
[...]
info depth 20 seldepth 2 multipv 1 score mate 1 nodes 742 nps 742000 tbhits 0 time 1 pv g7g8
bestmove g7g8

First seen here https://lichess.org/forum/lichess-feedback/racing-kings-ai.

Most helpful comment

This issue shows that our definition of checks in racing kings can be misleading, so I have submitted a test for a simplification.

All 8 comments

git bisect blames ab954aec613a8b85029fc270000d045ac5cd459d as the first bad commit.

setoption name uci_variant value racingkings
position fen 8/k5K1/1r4Q1/2n2R2/8/8/6B1/8 w - - 4 16 moves g7g8
perft 1

does not return any moves. I think that this is caused by the early return in the generation of check evasions introduced in https://github.com/ddugovic/Stockfish/commit/ab954aec613a8b85029fc270000d045ac5cd459d. King advances to the 8th rank are handled as checks, so there are "evasions" in racing kings. Removing this early return should fix the issue.

Oh, thanks. I read the diff several times thinking that the early return was sound. @ddugovic: Perhaps we should add this position (or another near-end racing kings position) to the bench suite.

This issue shows that our definition of checks in racing kings can be misleading, so I have submitted a test for a simplification.

Thanks. In hindsight that simplification makes great sense and as of this test we know that handling a "king promotion" like a check does not improve performance.

Additionally I can see that the simplification fixes an assertion bug ab954aec613a8b85029fc270000d045ac5cd459d introduced:

make build ARCH=x86-64-bmi2 debug=yes
./stockfish bench racingkings
...
Position: 1/2
info depth 1 seldepth 1 multipv 1 score cp 175 nodes 107 nps 53500 tbhits 0 time 2 pv f2d4
info depth 2 seldepth 2 multipv 1 score cp 351 nodes 174 nps 87000 tbhits 0 time 2 pv f2d4 a2b3 e1c2
info depth 3 seldepth 3 multipv 1 score cp 351 nodes 250 nps 125000 tbhits 0 time 2 pv f2d4 a2b3 e1c2
info depth 4 seldepth 4 multipv 1 score cp 383 nodes 518 nps 172666 tbhits 0 time 3 pv f2d4 a2b3 e1c2 b2c2 d4a1 b1a1
info depth 5 seldepth 5 multipv 1 score cp 243 nodes 2378 nps 396333 tbhits 0 time 6 pv f2d4 c2e4 h2g3 a2b3 g3f4 b3a4 e2c1 e4g2
info depth 6 seldepth 6 multipv 1 score cp 236 nodes 6227 nps 518916 tbhits 0 time 12 pv f2d4 c2e4 h2g3 a2b3 g3f4 e4g2 f1g2
info depth 7 seldepth 7 multipv 1 score cp 236 nodes 7539 nps 502600 tbhits 0 time 15 pv f2d4 c2e4 h2g3 a2b3 g3f4 e4g2 f1g2
info depth 8 seldepth 8 multipv 1 score cp 149 nodes 23989 nps 571166 tbhits 0 time 42 pv f2d4 a2b3 e1c2 a1a8 c2a3 b3a3 h2g3 a3a4
info depth 9 seldepth 12 multipv 1 score cp 207 nodes 45367 nps 574265 tbhits 0 time 79 pv f2d4 c2e4 h2g3 a2b3 h1h8 a1a5 g3f4 b3a4 e2c1 e4g2
info depth 10 seldepth 13 multipv 1 score cp 258 nodes 82598 nps 585801 tbhits 0 time 141 pv f2d4 c2e4 h2g3 a2b3 g3f4 b3c4 f4e5 a1a6 h1h8 d2f1 d4b2 b1b2 e5e4
stockfish: search.cpp:1411: Value {anonymous}::qsearch(Position&, Search::Stack*, Value, Value, Depth) [with {anonymous}::NodeType NT = (<unnamed>::NodeType)0u; bool InCheck = false]: Assertion `(pos.is_atomic() && pos.is_atomic_loss()) || InCheck == !!pos.checkers()' failed.
Aborted (core dumped)

According to the test result the current definition of checks seems to have an effect in qsearch, probably because it helps to correctly evaluate close-to-final positions more quickly. However, we should be able to achieve the same effect in other ways, so an improved version of the simplification might pass.

True, however owing to #278 simplifications which speed up normal chess are a good thing (even at some expense to variant performance). In hindsight performance matters most for the most popular variants:

  • normal
  • crazyhouse

304 is a Elo-neutral simplification to restore the definition of checks so that checks and evasions are not possible for racing kings.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ppigazzini picture ppigazzini  路  8Comments

Vinvin20 picture Vinvin20  路  14Comments

isaacl picture isaacl  路  9Comments

ddugovic picture ddugovic  路  10Comments

Truthdoc picture Truthdoc  路  12Comments