From: Fabian Fichter Date: Fri, 13 Jan 2023 19:10:14 +0000 (+0100) Subject: Correctly restrict to mustDropType X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=29ae8b76118db6d9a71357c8ca127142e2d38c33;p=fairystockfish.git Correctly restrict to mustDropType Closes #549. --- diff --git a/src/position.cpp b/src/position.cpp index 7003ac1..6cbdaa9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -980,9 +980,14 @@ bool Position::legal(Move m) const { return false; // Illegal non-drop moves - if (must_drop() && type_of(m) != DROP && count_in_hand(us, var->mustDropType) > 0) + if (must_drop() && count_in_hand(us, var->mustDropType) > 0) { - if (checkers()) + if (type_of(m) == DROP) + { + if (var->mustDropType != ALL_PIECES && var->mustDropType != in_hand_piece_type(m)) + return false; + } + else if (checkers()) { for (const auto& mevasion : MoveList(*this)) if (type_of(mevasion) == DROP && legal(mevasion)) diff --git a/tests/perft.sh b/tests/perft.sh index a34d052..2b71476 100755 --- a/tests/perft.sh +++ b/tests/perft.sh @@ -112,6 +112,8 @@ if [[ $1 == "all" || $1 == "variant" ]]; then expect perft.exp minishogi startpos 5 533203 > /dev/null expect perft.exp kyotoshogi startpos 5 225903 > /dev/null expect perft.exp torishogi startpos 4 103857 > /dev/null + expect perft.exp koedem "fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNB2BNR[KQ] w kq - 0 1" 1 34 > /dev/null + expect perft.exp koedem "fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNB1KBNR[Q] w KQkq - 0 1" 1 54 > /dev/null # non-chess expect perft.exp ataxx startpos 4 155888 > /dev/null expect perft.exp ataxx "fen 7/7/7/7/ppppppp/ppppppp/PPPPPPP w 0 1" 5 452980 > /dev/null