From e9e5f72c7440e6c9162a9578ae59fa2b75faf5f4 Mon Sep 17 00:00:00 2001 From: Alain SAVARD Date: Fri, 8 Apr 2016 19:19:59 +0100 Subject: [PATCH] Undefended King Ring There was already a penalty for squares only defended by King (undefended) This test records a penalty for completely undefended squares in the so called extended king-ring (so if we exclude squares defended by a Kg8 for example, we only look at h6 g6 and f6) We also exclude squares occupied by opponent pieces in this computation, based on the following results Was yellow at STC LLR: -2.97 (-2.94,2.94) [0.00,5.00] Total: 112499 W: 20649 L: 20293 D: 71557 and passed LTC LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 36805 W: 5100 L: 4857 D: 26848 Bench: 8430233 Resolves: #619 --- src/evaluate.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index da4b9c30..d00b862f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -384,14 +384,17 @@ namespace { // Main king safety evaluation if (ei.kingAttackersCount[Them]) { - // Find the attacked squares around the king which have no defenders - // apart from the king itself. + // Find the attacked squares which are defended only by the king... undefended = ei.attackedBy[Them][ALL_PIECES] & ei.attackedBy[Us][KING] & ~( ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]); + // ... and those which are not defended at all in the larger king ring + b = ei.attackedBy[Them][ALL_PIECES] & ~ei.attackedBy[Us][ALL_PIECES] + & ei.kingRing[Us] & ~pos.pieces(Them); + // Initialize the 'attackUnits' variable, which is used later on as an // index into the KingDanger[] array. The initial value is based on the // number and types of the enemy's attacking pieces, the number of @@ -400,7 +403,7 @@ namespace { attackUnits = std::min(72, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) + 9 * ei.kingAdjacentZoneAttacksCount[Them] + 27 * popcount(undefended) - + 11 * !!ei.pinnedPieces[Us] + + 11 * (popcount(b) + !!ei.pinnedPieces[Us]) - 64 * !pos.count(Them) - mg_value(score) / 8; -- 2.39.2