Micro-optimise dangerous condition
authorChris Caino <chricainogithub@gmail.com>
Wed, 4 Dec 2013 15:49:01 +0000 (15:49 +0000)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 4 Dec 2013 16:51:25 +0000 (17:51 +0100)
Since all ENPASSANT moves are now considered dangerous, this
change of order should give a slight speedup.

Also simplify futilityValue formula.

No functional change.

src/search.cpp

index 23ce40f489859f36f52481cc92bc0c0466b373d1..b8b325e57202f885ee24ee727f35fb11d59d1898 100644 (file)
@@ -807,8 +807,8 @@ moves_loop: // When in check and at SpNode search starts from here
       captureOrPromotion = pos.capture_or_promotion(move);
       givesCheck = pos.gives_check(move, ci);
       dangerous =   givesCheck
-                 || pos.advanced_pawn_push(move)
-                 || type_of(move) == CASTLING;
+                 || type_of(move) != NORMAL
+                 || pos.advanced_pawn_push(move);
 
       // Step 12. Extend checks
       if (givesCheck && pos.see_sign(move) >= 0)
@@ -1210,9 +1210,9 @@ moves_loop: // When in check and at SpNode search starts from here
           &&  futilityBase > -VALUE_KNOWN_WIN
           && !pos.advanced_pawn_push(move))
       {
-          futilityValue =  futilityBase
-                         + PieceValue[EG][pos.piece_on(to_sq(move))]
-                         + (type_of(move) == ENPASSANT ? PawnValueEg : VALUE_ZERO);
+          assert(type_of(move) != ENPASSANT); // Due to !pos.advanced_pawn_push
+
+          futilityValue = futilityBase + PieceValue[EG][pos.piece_on(to_sq(move))];
 
           if (futilityValue < beta)
           {