X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=9739a0018ab24861f5fea5d811cd3bd2ad2b3823;hp=da4b9c30b41c3e9d3f4ac17641e7a8fcb3f28233;hb=d30994ecd54bf96db88016fb6d92ff2c4614bc2e;hpb=8fb45caadef67fb2ccc27857c15ade987d9f5e2f diff --git a/src/evaluate.cpp b/src/evaluate.cpp index da4b9c30..9739a001 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; @@ -611,9 +614,6 @@ namespace { mbonus += rr + r * 2, ebonus += rr + r * 2; } // rr != 0 - if (pos.count(Us) < pos.count(Them)) - ebonus += ebonus / 4; - score += make_score(mbonus, ebonus) + PassedFile[file_of(s)]; }