From 99808aee10cfd562fad5cfcccc990f45ddebab9d Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Thu, 29 Jul 2021 23:19:46 +0200 Subject: [PATCH] Fix insufficient material handling for makpong Closes #335. --- src/apiutil.h | 4 ++-- test.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apiutil.h b/src/apiutil.h index 7d7bde0..f51d899 100644 --- a/src/apiutil.h +++ b/src/apiutil.h @@ -322,11 +322,11 @@ inline bool has_insufficient_material(Color c, const Position& pos) { for (PieceType pt : { BISHOP, FERS, FERS_ALFIL, ALFIL, ELEPHANT }) colorbound |= pos.pieces(pt) & ~restricted; unbound = pos.pieces() ^ restricted ^ colorbound; - if ((colorbound & pos.pieces(c)) && (((DarkSquares & colorbound) && (~DarkSquares & colorbound)) || unbound || pos.stalemate_value() != VALUE_DRAW || pos.check_counting())) + if ((colorbound & pos.pieces(c)) && (((DarkSquares & colorbound) && (~DarkSquares & colorbound)) || unbound || pos.stalemate_value() != VALUE_DRAW || pos.check_counting() || pos.makpong())) return false; // Unbound pieces require one helper piece of either color - if ((pos.pieces(c) & unbound) && (popcount(pos.pieces() ^ restricted) >= 2 || pos.stalemate_value() != VALUE_DRAW || pos.check_counting())) + if ((pos.pieces(c) & unbound) && (popcount(pos.pieces() ^ restricted) >= 2 || pos.stalemate_value() != VALUE_DRAW || pos.check_counting() || pos.makpong())) return false; return true; diff --git a/test.py b/test.py index bc17df2..a0e0ccb 100644 --- a/test.py +++ b/test.py @@ -133,6 +133,11 @@ variant_positions = { "k7/8/8/8/8/8/8/KFF5[] w - - 0 1": (False, True), # KFF vs K "k7/8/8/8/8/8/8/KS6[] w - - 0 1": (False, True), # KS vs K }, + "makpong": { + "8/8/8/4k2K/5m~2/4m~3/8/8 w - 128 8 58": (True, False), # KFF vs K + "k7/n7/8/8/8/8/8/K7 w - - 0 1": (True, False), # K vs KN + "k7/8/8/8/8/8/8/K7 w - - 0 1": (True, True), # K vs K + }, "xiangqi": { "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1": (False, False), # startpos "5k3/4a4/3CN4/9/1PP5p/9/8P/4C4/4A4/2B1K4 w - - 0 46": (False, False), # issue #53 -- 1.7.0.4