]> git.sesse.net Git - stockfish/commitdiff
Optimize order of a few conditions in search
authorajithcj <achajo@yahoo.co.in>
Wed, 31 Aug 2016 05:51:52 +0000 (05:51 +0000)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 31 Aug 2016 11:47:45 +0000 (13:47 +0200)
Also fix size of KingDanger array to reduce memory footprint.

Small speed up of around 0.5%

No functional change.

src/evaluate.cpp
src/search.cpp

index 177d29345fa38613143630e7a01564f4ce58039b..d533eed8c76d17172c10632c2c0cdada03a5a7a6 100644 (file)
@@ -210,7 +210,7 @@ namespace {
   // in KingDanger[]. Various little "meta-bonuses" measuring the strength
   // of the enemy attack are added up into an integer, which is used as an
   // index to KingDanger[].
-  Score KingDanger[512];
+  Score KingDanger[400];
 
   // KingAttackWeights[PieceType] contains king attack weights by piece type
   const int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 7, 5, 4, 1 };
index 9dfa5193e99fd3e2e16889e6182470700aba58fa..7fafe933d5fda20eb2f9d60bb678c0cc796e4d81 100644 (file)
@@ -725,8 +725,8 @@ namespace {
     // Step 6. Razoring (skipped when in check)
     if (   !PvNode
         &&  depth < 4 * ONE_PLY
-        &&  eval + razor_margin[depth / ONE_PLY] <= alpha
-        &&  ttMove == MOVE_NONE)
+        &&  ttMove == MOVE_NONE
+        &&  eval + razor_margin[depth / ONE_PLY] <= alpha)
     {
         if (   depth <= ONE_PLY
             && eval + razor_margin[3 * ONE_PLY] <= alpha)
@@ -924,8 +924,8 @@ moves_loop: // When in check search starts from here
           && !captureOrPromotion
           && !inCheck
           && !givesCheck
-          && !pos.advanced_pawn_push(move)
-          &&  bestValue > VALUE_MATED_IN_MAX_PLY)
+          &&  bestValue > VALUE_MATED_IN_MAX_PLY
+          && !pos.advanced_pawn_push(move))
       {
           // Move count based pruning
           if (moveCountPruning)