]> git.sesse.net Git - stockfish/commitdiff
Test for legality only after futility pruning
authorMarco Costalba <mcostalba@gmail.com>
Mon, 23 May 2011 13:14:47 +0000 (15:14 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 23 May 2011 19:21:02 +0000 (20:21 +0100)
Although there is a small functional change it seems
an improvment of about 2% in speed !

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 94eb6155bf756bfc8f938b43cbd038947bd9ff75..e18a0aafb01405f8c3801fa0ed88b05a1b877799 100644 (file)
@@ -909,7 +909,7 @@ split_point_start: // At split points actual search starts from here
           moveCount = ++sp->moveCount;
           lock_release(&(sp->lock));
       }
           moveCount = ++sp->moveCount;
           lock_release(&(sp->lock));
       }
-      else if (move == excludedMove || !pos.pl_move_is_legal(move, pinned))
+      else if (move == excludedMove)
           continue;
       else
           moveCount++;
           continue;
       else
           moveCount++;
@@ -950,6 +950,7 @@ split_point_start: // At split points actual search starts from here
       // a margin then we extend ttMove.
       if (   singularExtensionNode
           && move == ttMove
       // a margin then we extend ttMove.
       if (   singularExtensionNode
           && move == ttMove
+          && pos.pl_move_is_legal(move, pinned)
           && ext < ONE_PLY)
       {
           Value ttValue = value_from_tt(tte->value(), ss->ply);
           && ext < ONE_PLY)
       {
           Value ttValue = value_from_tt(tte->value(), ss->ply);
@@ -969,7 +970,6 @@ split_point_start: // At split points actual search starts from here
       }
 
       // Update current move (this must be done after singular extension search)
       }
 
       // Update current move (this must be done after singular extension search)
-      ss->currentMove = move;
       newDepth = depth - ONE_PLY + ext;
 
       // Step 12. Futility pruning (is omitted in PV nodes)
       newDepth = depth - ONE_PLY + ext;
 
       // Step 12. Futility pruning (is omitted in PV nodes)
@@ -1024,6 +1024,12 @@ split_point_start: // At split points actual search starts from here
           }
       }
 
           }
       }
 
+      // Check for legality only before to do the move
+      if (!pos.pl_move_is_legal(move, pinned))
+          continue;
+
+      ss->currentMove = move;
+
       // Step 13. Make the move
       pos.do_move(move, st, ci, givesCheck);
 
       // Step 13. Make the move
       pos.do_move(move, st, ci, givesCheck);
 
@@ -1334,9 +1340,6 @@ split_point_start: // At split points actual search starts from here
     {
       assert(move_is_ok(move));
 
     {
       assert(move_is_ok(move));
 
-      if (!pos.pl_move_is_legal(move, pinned))
-          continue;
-
       givesCheck = pos.move_gives_check(move, ci);
 
       // Futility pruning
       givesCheck = pos.move_gives_check(move, ci);
 
       // Futility pruning
@@ -1396,6 +1399,10 @@ split_point_start: // At split points actual search starts from here
           continue;
       }
 
           continue;
       }
 
+      // Check for legality only before to do the move
+      if (!pos.pl_move_is_legal(move, pinned))
+          continue;
+
       // Update current move
       ss->currentMove = move;
 
       // Update current move
       ss->currentMove = move;