From 33019af5781605af51d47b18116b052a4e8a1951 Mon Sep 17 00:00:00 2001 From: Ada Joule Date: Sun, 12 Sep 2021 19:15:15 +0700 Subject: [PATCH] Ignore countStarted when either side has only one piece --- src/position.h | 2 +- test.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/position.h b/src/position.h index b09171d..6e7c1dc 100644 --- a/src/position.h +++ b/src/position.h @@ -1171,7 +1171,7 @@ inline int Position::game_ply() const { } inline int Position::counting_ply(int countStarted) const { - return countStarted == 0 ? st->countingPly : std::min(st->countingPly, std::max(1 + gamePly - countStarted, 0)); + return countStarted == 0 || (count(WHITE) <= 1 || count(BLACK) <= 1) ? st->countingPly : std::min(st->countingPly, std::max(1 + gamePly - countStarted, 0)); } inline int Position::rule50_count() const { diff --git a/test.py b/test.py index 019a19a..2dc7f5b 100644 --- a/test.py +++ b/test.py @@ -359,6 +359,17 @@ class TestPyffish(unittest.TestCase): result = sf.get_fen("makruk", fen, moves, False, False, True) self.assertEqual(result, "8/2K3k1/5S2/6S1/8/8/8/8 b - 44 8 1") + # ignore count_started for piece honor counting + fen = "8/3k4/8/2K1S1P1/8/8/8/8 w - - 0 1" + moves = ["g5g6m"] + result = sf.get_fen("makruk", fen, moves, False, False, True, -1) + self.assertEqual(result, "8/3k4/6M~1/2K1S3/8/8/8/8 b - 88 8 1") + + fen = "8/2K3k1/5m2/4S1S1/8/8/8/8 w - 128 1 30" + moves = ["e5f6"] + result = sf.get_fen("makruk", fen, moves, False, False, True, 58) + self.assertEqual(result, "8/2K3k1/5S2/6S1/8/8/8/8 b - 44 8 30") + # makruk board honor counting fen = "3k4/2m5/8/4MP2/3KS3/8/8/8 w - - 0 1" moves = ["f5f6m"] -- 1.7.0.4