Rxg7 is obviously the blunder that leads to a draw (crazy rook).
I've seen this kind of pattern occur many times, and every time it really pisses me off that my engine doesn't understand this. A brute force search inevitably plays the materialistic Rxg7, and the search keeps shuffling the wood to delay the 3-rep draw, meaning that it may take a lot of depth to solve, if at all!
So I tried a rather radical approach which is to detect such things in the eval directly. Here's how it works:
1/ calculate the eval normally, let's call it e
2/ if the side to move has a persistent stalemate threat, return max(0,e)
3/ if the other side has a persistent stalemate threat, return min(0,e)
A side has a persistent stalemate threat if:
1/ the squares around the king are all attacked
2/ we have a rook or a queen that can deliver check
All this is fortunately quick to compute as there are many early exit cases, and I have some precalculated attacks available (a bitboard by piece type and side).
The position after Rxg7 is now evaluated as a draw, and the search gives credible results
Code: Select all
info score cp 459 depth 1 nodes 205 time 0 pv h5h6
info score cp 422 depth 2 nodes 520 time 0 pv g6d6 h8h7
info score cp 414 depth 3 nodes 2073 time 0 pv g6c6 h8h7 c6f6 b5b4 f6f4
info score cp 400 depth 4 nodes 3027 time 0 pv g6c6 b5b4 c6c4 b4c4 c7c4 g7e5
info score cp 403 depth 5 nodes 4499 time 0 pv g6c6 h8h7 c6f6 b5b4 f6f4 b4b5
info score cp 400 depth 6 nodes 9731 time 10 pv g6c6 h8h7 c6e6 b5b4 g4f3 b4b3 f3f4 b3b5
info score cp 396 depth 7 nodes 33230 time 40 pv g6e6 h8h7 e6e4 h7h6 c7c6 h6h7 e4e6
info score cp 395 depth 8 nodes 43219 time 60 pv g6e6 h8h7 e6e4 h7h6 c7c6 h6h7 e4e6
info score cp 396 depth 9 nodes 91207 time 120 pv c7c8 h8h7 c8c4 g7e5 c4e4 b5c5 g6g5 e5d6 e4e6 c5c4 g4f3
info score cp 408 depth 10 nodes 341693 time 320 pv c7c4 h8h7 c4e4 b5c5 e4e7 h7h8 g6e6 c5c4 e6e4 c4e4 e7e4 h8h7
info score cp 429 depth 11 nodes 670798 time 650 pv g6c6 b5b4 g4f5 b4b1 h5h6 b1f1 f5g4 f1g1
info score cp 469 depth 12 nodes 885881 time 800 pv g6a6 b5b4 g4g5 b4b8 h5h6 g7d4 a6e6 d4b6 c7d7 b8g8 g5f5 b6c5 e6e5 c5b4
info score cp 471 depth 13 nodes 1058588 time 910 pv g6a6 b5b4 g4g5 b4b1 h5h6 b1g1 g5f4 g1f1 f4e4 f1e1 e4f3 g7f8 a6a8 e1f1 f3e4 h8g8 c7d7 f1f2
info score cp 507 depth 14 nodes 2135735 time 1600 pv h5h6
info score cp 499 depth 15 nodes 4060606 time 2680 pv h5h6 g7e5 c7e7 e5b2 g6c6 b5b8 g4h5 b8f8 c6c7 b2f6
info score cp 492 depth 16 nodes 4539747 time 2990 pv h5h6 g7e5 c7e7 e5b2
info score cp 496 depth 17 nodes 5866752 time 3840 pv h5h6 g7e5 c7e7 e5b2
info score cp 504 depth 18 nodes 11502784 time 7320 pv h5h6 g7b2 g6g5 b5b8 g5d5 h8g8 g4h5 b8e8 c7a7
info score cp 504 depth 19 nodes 13247685 time 8420 pv h5h6 g7b2 g6g5 b5b8 g5d5 h8g8 g4h5 b8f8 d5g5 g8h8 g5c5 b2d4 c5d5
Has anyone tested other ways to fix this problem ?
