From d3ffd0ffcad5e467fffd67d82d031fa1cbdba7d2 Mon Sep 17 00:00:00 2001 From: snicolet Date: Sun, 27 Apr 2014 01:35:46 +0200 Subject: [PATCH] Penalize hanging pieces Passed both STC LLR: 2.95 (-2.94,2.94) [-1.50,4.50] Total: 8519 W: 1565 L: 1440 D: 5514 And LTC LLR: 2.95 (-2.94,2.94) [0.00,6.00] Total: 60618 W: 9141 L: 8777 D: 42700 bench: 8678654 --- src/evaluate.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index ede94ec0..be53a73e 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -158,6 +158,9 @@ namespace { S(0, 0), S(0, 0), S(56, 70), S(56, 70), S(76, 99), S(86, 118) }; + // Hanging[side to move] contains a bonus for each enemy hanging piece + const Score Hanging[2] = { S(23, 20) , S(35, 45) }; + #undef S const Score Tempo = make_score(24, 11); @@ -527,7 +530,7 @@ namespace { if (undefendedMinors) score += UndefendedMinor; - // Enemy pieces not defended by a pawn and under our attack + // Enemies not defended by a pawn and under our attack weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN] & ei.attackedBy[Us][ALL_PIECES]; @@ -535,13 +538,18 @@ namespace { // Add a bonus according if the attacking pieces are minor or major if (weakEnemies) { - b = weakEnemies & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); + b = weakEnemies & (ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); if (b) score += Threat[0][type_of(pos.piece_on(lsb(b)))]; b = weakEnemies & (ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]); if (b) score += Threat[1][type_of(pos.piece_on(lsb(b)))]; + + b = weakEnemies & ~ei.attackedBy[Them][ALL_PIECES]; + if (b) + score += more_than_one(b) ? Hanging[Us != pos.side_to_move()] * popcount(b) + : Hanging[Us == pos.side_to_move()]; } if (Trace) -- 2.39.2