]> git.sesse.net Git - stockfish/commitdiff
Simplify previous patch
authorMarco Costalba <mcostalba@gmail.com>
Wed, 8 May 2013 21:06:21 +0000 (23:06 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 9 May 2013 17:09:51 +0000 (19:09 +0200)
No functional change.

src/evaluate.cpp

index 94ec2b6c04162f8ba7c3e9e08395f4942993c88b..409024f1112685bcc97e0008d0bb23ee28c38dc9 100644 (file)
@@ -899,30 +899,19 @@ Value do_evaluate(const Position& pos, Value& margin) {
                 else
                     unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
 
-                // Default bonus for the empty square in front
-                int bonusMultiplier = 3;
+                // If there aren't enemy attacks huge bonus, a bit smaller if at
+                // least block square is not attacked, otherwise smallest bonus.
+                int k = !unsafeSquares ? 15 : !(unsafeSquares & blockSq) ? 9 : 3;
 
-                if ((defendedSquares & SquareBB[blockSq]) != 0)
-                {
-                    // Defending the square in front
-                    bonusMultiplier += 2;
-                    if ((unsafeSquares & defendedSquares) == unsafeSquares)
-                        // Defending all the attacked squares
-                        // bigger bonus if we are defending everything
-                        bonusMultiplier += (squaresToQueen == defendedSquares) ? 4 : 2;
-                }
+                // Big bonus if the path to queen is fully defended, a bit less
+                // if at least block square is defended.
+                if (defendedSquares == squaresToQueen)
+                    k += 6;
 
-                if ((unsafeSquares & SquareBB[blockSq]) == 0)
-                {
-                    // The square infront isn't attacked
-                    bonusMultiplier += 6;
-                    if (!unsafeSquares)
-                        bonusMultiplier += 6;
-                }
+                else if (defendedSquares & blockSq)
+                    k += (unsafeSquares & defendedSquares) == unsafeSquares ? 4 : 2;
 
-                Value bonus = Value(rr * bonusMultiplier);
-                ebonus += bonus;
-                mbonus += bonus;
+                mbonus += Value(k * rr), ebonus += Value(k * rr);
             }
         } // rr != 0