X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=ac9cf90bdcb314aad1198af283f0ab8d9662eb6c;hp=9d98a63b6cd15afb6badaf708423c9dd5881e471;hb=a4eda3056ef7f6f69ae15925255621cb32443de9;hpb=d2d4e85f25061aacd65a8b458b79cad15b74a5bb diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 9d98a63b..ac9cf90b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -154,20 +154,17 @@ namespace { // PassedDanger[Rank] contains a term to weight the passed score constexpr int PassedDanger[RANK_NB] = { 0, 0, 0, 3, 7, 11, 20 }; - // KingProtector[knight/bishop] contains a penalty according to distance from king - constexpr Score KingProtector[] = { S(5, 6), S(6, 5) }; - // Assorted bonuses and penalties constexpr Score BishopPawns = S( 3, 7); constexpr Score CloseEnemies = S( 6, 0); - constexpr Score Connectivity = S( 3, 1); constexpr Score CorneredBishop = S( 50, 50); constexpr Score Hanging = S( 52, 30); constexpr Score HinderPassedPawn = S( 4, 0); + constexpr Score KingProtector = S( 6, 6); constexpr Score KnightOnQueen = S( 21, 11); constexpr Score LongDiagonalBishop = S( 22, 0); constexpr Score MinorBehindPawn = S( 16, 0); - constexpr Score Overload = S( 10, 5); + constexpr Score Overload = S( 13, 6); constexpr Score PawnlessFlank = S( 20, 80); constexpr Score RookOnPawn = S( 8, 24); constexpr Score SliderOnQueen = S( 42, 21); @@ -337,13 +334,12 @@ namespace { else if (bb &= b & ~pos.pieces(Us)) score += Outpost[Pt == BISHOP][bool(attackedBy[Us][PAWN] & bb)]; - // Bonus when behind a pawn - if ( relative_rank(Us, s) < RANK_5 - && (pos.pieces(PAWN) & (s + pawn_push(Us)))) + // Knight and Bishop bonus for being right behind a pawn + if (shift(pos.pieces(PAWN)) & s) score += MinorBehindPawn; // Penalty if the piece is far from the king - score -= KingProtector[Pt == BISHOP] * distance(s, pos.square(Us)); + score -= KingProtector * distance(s, pos.square(Us)); if (Pt == BISHOP) { @@ -544,27 +540,29 @@ namespace { score += ThreatByMinor[type_of(pos.piece_on(s))]; if (type_of(pos.piece_on(s)) != PAWN) score += ThreatByRank * (int)relative_rank(Them, s); + + else if (pos.blockers_for_king(Them) & s) + score += ThreatByRank * (int)relative_rank(Them, s) / 2; } - b = (pos.pieces(Them, QUEEN) | weak) & attackedBy[Us][ROOK]; + b = weak & attackedBy[Us][ROOK]; while (b) { Square s = pop_lsb(&b); score += ThreatByRook[type_of(pos.piece_on(s))]; if (type_of(pos.piece_on(s)) != PAWN) score += ThreatByRank * (int)relative_rank(Them, s); + + else if (pos.blockers_for_king(Them) & s) + score += ThreatByRank * (int)relative_rank(Them, s) / 2; } - // Bonus for king attacks on pawns or pieces which are not pawn-defended if (weak & attackedBy[Us][KING]) score += ThreatByKing; 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]; + b = weak & nonPawnEnemies & attackedBy[Them][ALL_PIECES]; score += Overload * popcount(b); } @@ -583,7 +581,7 @@ namespace { b = shift(pos.pieces(Us, PAWN)) & ~pos.pieces(); b |= shift(b & TRank3BB) & ~pos.pieces(); - // Keep only the squares which are not completely unsafe + // Keep only the squares which are relatively safe b &= ~attackedBy[Them][PAWN] & (attackedBy[Us][ALL_PIECES] | ~attackedBy[Them][ALL_PIECES]); @@ -610,10 +608,6 @@ namespace { score += SliderOnQueen * popcount(b & safeThreats & attackedBy2[Us]); } - // Connectivity: ensure that knights, bishops, rooks, and queens are protected - b = (pos.pieces(Us) ^ pos.pieces(Us, PAWN, KING)) & attackedBy[Us][ALL_PIECES]; - score += Connectivity * popcount(b); - if (T) Trace::add(THREAT, Us, score);