From: Marco Costalba Date: Mon, 23 May 2011 13:14:47 +0000 (+0200) Subject: Test for legality only after futility pruning X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=9884573561c6ad58f50fb2fd96a54fd192c5aedf Test for legality only after futility pruning Although there is a small functional change it seems an improvment of about 2% in speed ! Signed-off-by: Marco Costalba --- diff --git a/src/search.cpp b/src/search.cpp index 94eb6155..e18a0aaf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -909,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 || !pos.pl_move_is_legal(move, pinned)) + else if (move == excludedMove) 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 + && pos.pl_move_is_legal(move, pinned) && 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) - ss->currentMove = move; 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); @@ -1334,9 +1340,6 @@ 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 @@ -1396,6 +1399,10 @@ split_point_start: // At split points actual search starts from here 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;