From 270b241ec12ad3a32634a846b87ec9dc08fa2730 Mon Sep 17 00:00:00 2001 From: protonspring Date: Wed, 11 Sep 2019 12:36:58 -0600 Subject: [PATCH] Simplify Weak Lever 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 | 18 +++++++----------- src/types.h | 5 +++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pawns.cpp b/src/pawns.cpp index 33e859e5..1ae65bf1 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -71,10 +71,10 @@ namespace { 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; - bool opposed, backward, passed; + bool opposed, backward, passed, doubled; Score score = SCORE_ZERO; const Square* pl = pos.squares(Us); @@ -137,20 +137,16 @@ namespace { } else if (!neighbours) - score -= Isolated + WeakUnopposed * int(!opposed); + score -= Isolated + WeakUnopposed * !opposed; 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; } diff --git a/src/types.h b/src/types.h index 934f884e..c77d8040 100644 --- a/src/types.h +++ b/src/types.h @@ -345,6 +345,11 @@ inline Score operator*(Score s, int i) { 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 } -- 2.39.2