diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 99e9f047..8c84ac29 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -204,6 +204,8 @@ namespace { const int BishopCheck = 2; const int KnightCheck = 3; + const int UnsupportedPinnedPiece = 2; + // KingDanger[Color][attackUnits] contains the actual king danger weighted // scores, indexed by color and by a calculated integer number. Score KingDanger[COLOR_NB][128]; @@ -693,6 +695,10 @@ Value do_evaluate(const Position& pos) { if (b) attackUnits += KnightCheck * popcount(b); + // Penalty for pinned pieces not defended by a pawn + if (ei.pinnedPieces[Us] & ~ei.attackedBy[Us][PAWN]) + attackUnits += UnsupportedPinnedPiece; + // To index KingDanger[] attackUnits must be in [0, 99] range attackUnits = std::min(99, std::max(0, attackUnits));