qsearch: do not prune pv nodes with negative SEE
authorMarco Costalba <mcostalba@gmail.com>
Tue, 11 Nov 2008 20:42:36 +0000 (21:42 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Nov 2008 11:37:47 +0000 (12:37 +0100)
Also small micro-optimization, take a line out of
the moves loop.

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

index e2d4093ad6e6ccb8bbcc28a1b14ec6aa0c37f236..7cc307d854705baeff687b39de006f75e379ea17 100644 (file)
@@ -1394,6 +1394,8 @@ namespace {
     int moveCount = 0;
     Bitboard dcCandidates = mp.discovered_check_candidates();
     bool isCheck = pos.is_check();
+    bool pvNode = (beta - alpha != 1);
+    bool enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame;
 
     // Loop through the moves until no moves remain or a beta cutoff
     // occurs.
@@ -1414,8 +1416,8 @@ namespace {
           && !moveIsCheck
           && !move_promotion(move)
           && !moveIsPassedPawnPush
-          &&  beta - alpha == 1
-          &&  pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame)
+          && !pvNode
+          &&  enoughMaterial)
       {
           Value futilityValue = staticValue
                               + Max(pos.midgame_value_of_piece_on(move_to(move)),
@@ -1431,9 +1433,10 @@ namespace {
           }
       }
 
-      // Don't search captures and checks with negative SEE values.
+      // Don't search captures and checks with negative SEE values
       if (   !isCheck
           && !move_promotion(move)
+          && !pvNode
           && (pos.midgame_value_of_piece_on(move_from(move)) >
               pos.midgame_value_of_piece_on(move_to(move)))
           &&  pos.see(move) < 0)