Skip to content

Commit 2fbb4d0

Browse files
committed
Fix and add test syzygy DTZ bug
See official-stockfish/Stockfish@6e2ca97d93812b2.
1 parent 3e85b6f commit 2fbb4d0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

chess/syzygy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,10 +1465,10 @@ def probe_dtz_no_ep(self, board):
14651465

14661466
board.push(move)
14671467

1468-
v_plus, success = self.probe_ab(board, -2, -wdl + 1)
1468+
v_plus = self.probe_wdl(board)
14691469
board.pop()
14701470

1471-
if v_plus is None or not success:
1471+
if v_plus is None:
14721472
return None
14731473

14741474
v = -v_plus

test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ def test_probe_dtz_table_pawn(self):
24372437

24382438
def test_probe_wdl_tablebase(self):
24392439
tablebases = chess.syzygy.Tablebases(max_fds=2)
2440-
self.assertEqual(tablebases.open_directory("data/syzygy"), 70)
2440+
self.assertTrue(tablebases.open_directory("data/syzygy") >= 70)
24412441

24422442
# Winning KRvKB.
24432443
board = chess.Board("7k/6b1/6K1/8/8/8/8/3R4 b - - 12 7")
@@ -2502,6 +2502,15 @@ def test_testsuite(self):
25022502

25032503
tablebases.close()
25042504

2505+
def test_stockfish_dtz_bug(self):
2506+
board = chess.Board("3K4/8/3k4/8/4p3/4B3/5P2/8 w - - 0 5")
2507+
tablebases = chess.syzygy.Tablebases("data/syzygy")
2508+
dtz = tablebases.probe_dtz(board)
2509+
if dtz is None:
2510+
self.skipTest("need KBPvKP.rtbz and its children")
2511+
self.assertEqual(tablebases.probe_dtz(board), 15)
2512+
tablebases.close()
2513+
25052514

25062515
class NativeGaviotaTestCase(unittest.TestCase):
25072516

0 commit comments

Comments
 (0)