]> git.sesse.net Git - stockfish/commitdiff
Rank based threats
authormbootsector <mbootsector@gmail.com>
Fri, 25 Nov 2016 16:47:18 +0000 (17:47 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 27 Nov 2016 08:05:57 +0000 (09:05 +0100)
STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 19404 W: 3581 L: 3374 D: 12449

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 16204 W: 2194 L: 2023 D: 11987

Bench: 5757843

src/evaluate.cpp

index 434ebd6241249f21869fe6b6b58211a61febe325..8987b0ecd0a72cc7337404f604ecb951b254e889 100644 (file)
@@ -200,6 +200,7 @@ namespace {
   const Score Unstoppable         = S( 0, 20);
   const Score PawnlessFlank       = S(20, 80);
   const Score HinderPassedPawn    = S( 7,  0);
   const Score Unstoppable         = S( 0, 20);
   const Score PawnlessFlank       = S(20, 80);
   const Score HinderPassedPawn    = S( 7,  0);
+  const Score ThreatByRank        = S(16,  3);
 
   // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
   // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
 
   // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
   // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
@@ -561,11 +562,21 @@ namespace {
     {
         b = (defended | weak) & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
         while (b)
     {
         b = (defended | weak) & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]);
         while (b)
-            score += Threat[Minor][type_of(pos.piece_on(pop_lsb(&b)))];
+        {
+            Square s = pop_lsb(&b);
+            score += Threat[Minor][type_of(pos.piece_on(s))];
+            if (type_of(pos.piece_on(s)) != PAWN)
+                score += ThreatByRank * (int)relative_rank(Them, s);
+        }
 
         b = (pos.pieces(Them, QUEEN) | weak) & ei.attackedBy[Us][ROOK];
         while (b)
 
         b = (pos.pieces(Them, QUEEN) | weak) & ei.attackedBy[Us][ROOK];
         while (b)
-            score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];
+        {
+            Square s = pop_lsb(&b);
+            score += Threat[Rook][type_of(pos.piece_on(s))];
+            if (type_of(pos.piece_on(s)) != PAWN)
+                score += ThreatByRank * (int)relative_rank(Them, s);
+        }
 
         score += Hanging * popcount(weak & ~ei.attackedBy[Them][ALL_PIECES]);
 
 
         score += Hanging * popcount(weak & ~ei.attackedBy[Them][ALL_PIECES]);