]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Move legal check out of MovePicker
[stockfish] / src / search.cpp
index 516ff100868655264da9f18a7f2b6282eb61a474..94eb6155bf756bfc8f938b43cbd038947bd9ff75 100644 (file)
@@ -880,6 +880,7 @@ split_point_start: // At split points actual search starts from here
     // Initialize a MovePicker object for the current position
     MovePickerExt<SpNode, Root> mp(pos, ttMove, depth, H, ss, (PvNode ? -VALUE_INFINITE : beta));
     CheckInfo ci(pos);
+    Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
     ss->bestMove = MOVE_NONE;
     futilityBase = ss->eval + ss->evalMargin;
     singularExtensionNode =   !Root
@@ -908,7 +909,7 @@ split_point_start: // At split points actual search starts from here
           moveCount = ++sp->moveCount;
           lock_release(&(sp->lock));
       }
-      else if (move == excludedMove)
+      else if (move == excludedMove || !pos.pl_move_is_legal(move, pinned))
           continue;
       else
           moveCount++;
@@ -1325,6 +1326,7 @@ split_point_start: // At split points actual search starts from here
     // be generated.
     MovePicker mp(pos, ttMove, depth, H);
     CheckInfo ci(pos);
+    Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
 
     // Loop through the moves until no moves remain or a beta cutoff occurs
     while (   alpha < beta
@@ -1332,6 +1334,9 @@ split_point_start: // At split points actual search starts from here
     {
       assert(move_is_ok(move));
 
+      if (!pos.pl_move_is_legal(move, pinned))
+          continue;
+
       givesCheck = pos.move_gives_check(move, ci);
 
       // Futility pruning