]> git.sesse.net Git - stockfish/commitdiff
Simplify Weak Lever
authorprotonspring <mike@whiteley.org>
Wed, 11 Sep 2019 18:36:58 +0000 (12:36 -0600)
committerStéphane Nicolet <cassio@free.fr>
Thu, 12 Sep 2019 07:44:40 +0000 (09:44 +0200)
This is a simplification that integrated WeakLever into doubled pawns.
Since we already check for !support for Doubled pawns, it is trivial
to check for weak lever by just checking more_than_one(lever).

We also introduce the Score * bool operation overload to remove some
casts in the code.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 26757 W: 5842 L: 5731 D: 15184
http://tests.stockfishchess.org/tests/view/5d77ee220ebc5902d384e5a4

Closes https://github.com/official-stockfish/Stockfish/pull/2295

No functional change

src/pawns.cpp
src/types.h

index 33e859e5a3d49b769b1ae0500393842399a8f2c9..1ae65bf181bcb74dac8755704776bf95a31a3a4c 100644 (file)
@@ -71,10 +71,10 @@ namespace {
     constexpr Color     Them = (Us == WHITE ? BLACK : WHITE);
     constexpr Direction Up   = (Us == WHITE ? NORTH : SOUTH);
 
     constexpr Color     Them = (Us == WHITE ? BLACK : WHITE);
     constexpr Direction Up   = (Us == WHITE ? NORTH : SOUTH);
 
-    Bitboard neighbours, stoppers, doubled, support, phalanx;
+    Bitboard neighbours, stoppers, support, phalanx;
     Bitboard lever, leverPush;
     Square s;
     Bitboard lever, leverPush;
     Square s;
-    bool opposed, backward, passed;
+    bool opposed, backward, passed, doubled;
     Score score = SCORE_ZERO;
     const Square* pl = pos.squares<PAWN>(Us);
 
     Score score = SCORE_ZERO;
     const Square* pl = pos.squares<PAWN>(Us);
 
@@ -137,20 +137,16 @@ namespace {
         }
 
         else if (!neighbours)
         }
 
         else if (!neighbours)
-            score -= Isolated + WeakUnopposed * int(!opposed);
+            score -= Isolated + WeakUnopposed * !opposed;
 
         else if (backward)
 
         else if (backward)
-            score -= Backward + WeakUnopposed * int(!opposed);
+            score -= Backward + WeakUnopposed * !opposed;
 
 
-        if (doubled && !support)
-            score -= Doubled;
+        if (!support)
+            score -=   Doubled * doubled
+                     + WeakLever * more_than_one(lever);
     }
 
     }
 
-    // Penalize our unsupported pawns attacked twice by enemy pawns
-    score -= WeakLever * popcount(  ourPawns
-                                  & doubleAttackThem
-                                  & ~e->pawnAttacks[Us]);
-
     return score;
   }
 
     return score;
   }
 
index 934f884e8fb5b740e3b5f1a40dfcd57560c68b87..c77d804037ee7a094b54843b1482801baa2c6aed 100644 (file)
@@ -345,6 +345,11 @@ inline Score operator*(Score s, int i) {
   return result;
 }
 
   return result;
 }
 
+/// Multiplication of a Score by an boolean
+inline Score operator*(Score s, bool b) {
+  return Score(int(s) * int(b));
+}
+
 constexpr Color operator~(Color c) {
   return Color(c ^ BLACK); // Toggle color
 }
 constexpr Color operator~(Color c) {
   return Color(c ^ BLACK); // Toggle color
 }