Correctly restrict to mustDropType
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 13 Jan 2023 19:10:14 +0000 (20:10 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 14 Jan 2023 12:05:25 +0000 (13:05 +0100)
Closes #549.

src/position.cpp
tests/perft.sh

index 7003ac1..6cbdaa9 100644 (file)
@@ -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<EVASIONS>(*this))
               if (type_of(mevasion) == DROP && legal(mevasion))
index a34d052..2b71476 100755 (executable)
@@ -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