From 5935daf8a5b6925a6af2084f87e3831b3bb17dac Mon Sep 17 00:00:00 2001 From: protonspring Date: Sun, 9 Jun 2019 06:28:42 -0600 Subject: [PATCH] Simplify WeakUnopposedPawn #2181 This is a functional simplification. Moves WeakUnopposedPawn to pawns.cpp and remove piece dependency. STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 8699 W: 2000 L: 1853 D: 4846 http://tests.stockfishchess.org/tests/view/5cf7721b0ebc5925cf08ee79 LTC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 46605 W: 7969 L: 7890 D: 30746 http://tests.stockfishchess.org/tests/view/5cf7d5f70ebc5925cf08fa96 --- src/evaluate.cpp | 5 ----- src/pawns.cpp | 7 ++++--- src/pawns.h | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 30c22a8e..0da6ba4d 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -152,7 +152,6 @@ namespace { constexpr Score ThreatBySafePawn = S(173, 94); constexpr Score TrappedRook = S( 47, 4); constexpr Score WeakQueen = S( 49, 15); - constexpr Score WeakUnopposedPawn = S( 12, 23); #undef S @@ -555,10 +554,6 @@ namespace { score += RestrictedPiece * popcount(b); - // Bonus for enemy unopposed weak pawns - if (pos.pieces(Us, ROOK, QUEEN)) - score += WeakUnopposedPawn * pe->weak_unopposed(Them); - // Find squares where our pawns can push on the next move b = shift(pos.pieces(Us, PAWN)) & ~pos.pieces(); b |= shift(b & TRank3BB) & ~pos.pieces(); diff --git a/src/pawns.cpp b/src/pawns.cpp index 291d40b6..47c89ed4 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -35,6 +35,7 @@ namespace { constexpr Score Backward = S( 9, 24); constexpr Score Doubled = S(11, 56); constexpr Score Isolated = S( 5, 15); + constexpr Score WeakUnopposed = S( 13, 27); // Connected pawn bonus constexpr int Connected[RANK_NB] = { 0, 7, 8, 12, 29, 48, 86 }; @@ -77,7 +78,7 @@ namespace { Bitboard ourPawns = pos.pieces( Us, PAWN); Bitboard theirPawns = pos.pieces(Them, PAWN); - e->passedPawns[Us] = e->pawnAttacksSpan[Us] = e->weakUnopposed[Us] = 0; + e->passedPawns[Us] = e->pawnAttacksSpan[Us] = 0; e->kingSquares[Us] = SQ_NONE; e->pawnAttacks[Us] = pawn_attacks_bb(ourPawns); @@ -132,10 +133,10 @@ namespace { score += make_score(v, v * (r - 2) / 4); } else if (!neighbours) - score -= Isolated, e->weakUnopposed[Us] += !opposed; + score -= Isolated + WeakUnopposed * int(!opposed); else if (backward) - score -= Backward, e->weakUnopposed[Us] += !opposed; + score -= Backward + WeakUnopposed * int(!opposed); if (doubled && !support) score -= Doubled; diff --git a/src/pawns.h b/src/pawns.h index 771e9cd3..ef4b83f8 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -37,7 +37,6 @@ struct Entry { Bitboard pawn_attacks(Color c) const { return pawnAttacks[c]; } Bitboard passed_pawns(Color c) const { return passedPawns[c]; } Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; } - int weak_unopposed(Color c) const { return weakUnopposed[c]; } int passed_count() const { return popcount(passedPawns[WHITE] | passedPawns[BLACK]); } template @@ -59,7 +58,6 @@ struct Entry { Bitboard pawnAttacksSpan[COLOR_NB]; Square kingSquares[COLOR_NB]; Score kingSafety[COLOR_NB]; - int weakUnopposed[COLOR_NB]; int castlingRights[COLOR_NB]; int pawnsOnSquares[COLOR_NB][COLOR_NB]; // [color][light/dark squares] }; -- 2.39.2