From 66af80972a6ae085f6348d38ca5e4eb08734437d Mon Sep 17 00:00:00 2001 From: Alain SAVARD Date: Wed, 18 Apr 2018 19:44:22 +0200 Subject: [PATCH] Tidy up on Overload Move new code in the if (defended | weak) {} section. No functional change --- src/evaluate.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 69a36cf5..1505bf67 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -524,13 +524,6 @@ namespace { // Non-pawn enemies nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN); - // Our safe or protected pawns - b = pos.pieces(Us, PAWN) - & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]); - - safeThreats = pawn_attacks_bb(b) & nonPawnEnemies; - score += ThreatBySafePawn * popcount(safeThreats); - // Squares strongly protected by the enemy, either because they defend the // square with a pawn, or because they defend the square twice and we don't. stronglyProtected = attackedBy[Them][PAWN] @@ -563,17 +556,30 @@ namespace { score += ThreatByRank * (int)relative_rank(Them, s); } - score += Hanging * popcount(weak & ~attackedBy[Them][ALL_PIECES]); - b = weak & attackedBy[Us][KING]; if (b) score += ThreatByKing[more_than_one(b)]; + + score += Hanging * popcount(weak & ~attackedBy[Them][ALL_PIECES]); + + // Bonus for overload (non-pawn enemies attacked and defended exactly once) + b = nonPawnEnemies + & attackedBy[Us][ALL_PIECES] & ~attackedBy2[Us] + & attackedBy[Them][ALL_PIECES] & ~attackedBy2[Them]; + score += Overload * popcount(b); } // Bonus for enemy unopposed weak pawns if (pos.pieces(Us, ROOK, QUEEN)) score += WeakUnopposedPawn * pe->weak_unopposed(Them); + // Our safe or protected pawns + b = pos.pieces(Us, PAWN) + & (~attackedBy[Them][ALL_PIECES] | attackedBy[Us][ALL_PIECES]); + + safeThreats = pawn_attacks_bb(b) & nonPawnEnemies; + score += ThreatBySafePawn * popcount(safeThreats); + // 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(); @@ -609,12 +615,6 @@ namespace { b = (pos.pieces(Us) ^ pos.pieces(Us, PAWN, KING)) & attackedBy[Us][ALL_PIECES]; score += Connectivity * popcount(b); - // Bonus for overload (non-pawn enemies attacked and defended exactly once) - b = nonPawnEnemies - & attackedBy[Us][ALL_PIECES] & ~attackedBy2[Us] - & attackedBy[Them][ALL_PIECES] & ~attackedBy2[Them]; - score += Overload * popcount(b); - if (T) Trace::add(THREAT, Us, score); -- 2.39.2