]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Simplify code for pinaware SEE
[stockfish] / src / pawns.cpp
index 86745924bcfe2f308f04a1f9290a7b22d399f27b..b83b780ab00f21e8228889e8ea13c358d0ce2939 100644 (file)
@@ -31,12 +31,8 @@ namespace {
   #define V Value
   #define S(mg, eg) make_score(mg, eg)
 
-  // Isolated pawn penalty by opposed flag and file
-  const Score Isolated[2][FILE_NB] = {
-    { S(31, 36), S(45, 41), S(50, 41), S(50, 41),
-      S(50, 41), S(50, 41), S(45, 41), S(31, 36) },
-    { S(21, 24), S(30, 28), S(33, 28), S(33, 28),
-      S(33, 28), S(33, 28), S(30, 28), S(21, 24) } };
+  // Isolated pawn penalty by opposed flag
+  const Score Isolated[2] = { S(45, 40), S(30, 27) };
 
   // Backward pawn penalty by opposed flag
   const Score Backward[2] = { S(56, 33), S(41, 19) };
@@ -48,10 +44,8 @@ namespace {
   // Connected pawn bonus by opposed, phalanx, twice supported and rank
   Score Connected[2][2][2][RANK_NB];
 
-  // Doubled pawn penalty by file
-  const Score Doubled[FILE_NB] = {
-    S(11, 34), S(17, 38), S(19, 38), S(19, 38),
-    S(19, 38), S(19, 38), S(17, 38), S(11, 34) };
+  // Doubled pawn penalty
+  const Score Doubled = S(18,38);
 
   // Lever bonus by rank
   const Score Lever[RANK_NB] = {
@@ -130,7 +124,7 @@ namespace {
         opposed    = theirPawns & forward_bb(Us, s);
         stoppers   = theirPawns & passed_pawn_mask(Us, s);
         lever      = theirPawns & pawnAttacksBB[s];
-        doubled    = ourPawns   & forward_bb(Us, s);
+        doubled    = ourPawns   & (s + Up);
         neighbours = ourPawns   & adjacent_files_bb(f);
         phalanx    = neighbours & rank_bb(s);
         supported  = neighbours & rank_bb(s - Up);
@@ -149,19 +143,18 @@ namespace {
             // either there is a stopper in the way on this rank, or there is a
             // stopper on adjacent file which controls the way to that rank.
             backward = (b | shift_bb<Up>(b & adjacent_files_bb(f))) & stoppers;
-            
+
             assert(!backward || !(pawn_attack_span(Them, s + Up) & neighbours));
         }
 
         // Passed pawns will be properly scored in evaluation because we need
-        // full attack info to evaluate them. Only the frontmost passed
-        // pawn on each file is considered a true passed pawn.
-        if (!(stoppers | doubled))
+        // full attack info to evaluate them.
+        if (!stoppers && !(ourPawns & forward_bb(Us, s)))
             e->passedPawns[Us] |= s;
 
         // Score this pawn
         if (!neighbours)
-            score -= Isolated[opposed][f];
+            score -= Isolated[opposed];
 
         else if (backward)
             score -= Backward[opposed];
@@ -173,15 +166,12 @@ namespace {
             score += Connected[opposed][!!phalanx][more_than_one(supported)][relative_rank(Us, s)];
 
         if (doubled)
-            score -= Doubled[f] / distance<Rank>(s, frontmost_sq(Us, doubled));
+            score -= Doubled;
 
         if (lever)
             score += Lever[relative_rank(Us, s)];
     }
 
-    b = e->semiopenFiles[Us] ^ 0xFF;
-    e->pawnSpan[Us] = b ? int(msb(b) - lsb(b)) : 0;
-
     return score;
   }
 
@@ -225,6 +215,7 @@ Entry* probe(const Position& pos) {
   e->key = key;
   e->score = evaluate<WHITE>(pos, e) - evaluate<BLACK>(pos, e);
   e->asymmetry = popcount(e->semiopenFiles[WHITE] ^ e->semiopenFiles[BLACK]);
+  e->openFiles = popcount(e->semiopenFiles[WHITE] & e->semiopenFiles[BLACK]);
   return e;
 }