]> git.sesse.net Git - stockfish/commitdiff
Merge 'passed_pawns' tweaks
authorMarco Costalba <mcostalba@gmail.com>
Wed, 8 May 2013 21:02:08 +0000 (23:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 8 May 2013 21:04:11 +0000 (23:04 +0200)
Good at both short and long TC

15+0.05
LLR: 2.96 (-2.94,2.94)
Total: 28220 W: 5531 L: 5349 D: 17340

TC 60+0.05
LLR: 2.95 (-2.94,2.94)
Total: 12612 W: 2221 L: 2057 D: 8334

bench: 4857939

1  2 
src/evaluate.cpp

diff --combined src/evaluate.cpp
index 854ab42a1c3c132899e54dddd315653f2e60d11f,c2f025fccd87047034fea47ad8d8984b27b1b2ad..94ec2b6c04162f8ba7c3e9e08395f4942993c88b
@@@ -677,7 -677,8 +677,7 @@@ Value do_evaluate(const Position& pos, 
      Score score = SCORE_ZERO;
  
      // Undefended minors get penalized even if not under attack
 -    undefendedMinors =  pos.pieces(Them)
 -                      & (pos.pieces(BISHOP) | pos.pieces(KNIGHT))
 +    undefendedMinors =  pos.pieces(Them, BISHOP, KNIGHT)
                        & ~ei.attackedBy[Them][ALL_PIECES];
  
      if (undefendedMinors)
                  else
                      unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
  
-                 // If there aren't enemy attacks or pieces along the path to queen give
-                 // huge bonus. Even bigger if we protect the pawn's path.
-                 if (!unsafeSquares)
-                     ebonus += Value(rr * (squaresToQueen == defendedSquares ? 17 : 15));
-                 else
-                     // OK, there are enemy attacks or pieces (but not pawns). Are those
-                     // squares which are attacked by the enemy also attacked by us ?
-                     // If yes, big bonus (but smaller than when there are no enemy attacks),
-                     // if no, somewhat smaller bonus.
-                     ebonus += Value(rr * ((unsafeSquares & defendedSquares) == unsafeSquares ? 13 : 8));
+                 // Default bonus for the empty square in front
+                 int bonusMultiplier = 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;
+                 }
+                 if ((unsafeSquares & SquareBB[blockSq]) == 0)
+                 {
+                     // The square infront isn't attacked
+                     bonusMultiplier += 6;
+                     if (!unsafeSquares)
+                         bonusMultiplier += 6;
+                 }
+                 Value bonus = Value(rr * bonusMultiplier);
+                 ebonus += bonus;
+                 mbonus += bonus;
              }
          } // rr != 0