X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=77096c9b30f62d581d52c944051865913154bef9;hp=822be015bdf6395c6a66f34ebf926f7849f4415e;hb=41ccc885ece3f49139eee113493c3a0fdc51e4bf;hpb=18b08096399c0e316baa1999f8cc6ce56bc7f616 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 822be015..77096c9b 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -61,11 +61,11 @@ namespace { // KingAttackWeights array. int kingAttackersWeight[COLOR_NB]; - // kingAdjacentZoneAttacksCount[color] is the number of attacks to squares - // directly adjacent to the king of the given color. Pieces which attack - // more than one square are counted multiple times. For instance, if black's - // king is on g8 and there's a white knight on g5, this knight adds - // 2 to kingAdjacentZoneAttacksCount[BLACK]. + // kingAdjacentZoneAttacksCount[color] is the number of attacks by the given + // color to squares directly adjacent to the enemy king. Pieces which attack + // more than one square are counted multiple times. For instance, if there is + // a white knight on g5 and black's king is on g8, this white knight adds 2 + // to kingAdjacentZoneAttacksCount[WHITE]. int kingAdjacentZoneAttacksCount[COLOR_NB]; Bitboard pinnedPieces[COLOR_NB]; @@ -163,6 +163,7 @@ namespace { const Score Unstoppable = S( 0, 20); const Score Hanging = S(31, 26); const Score PawnAttackThreat = S(20, 20); + const Score PawnSafePush = S( 5, 5); // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only @@ -413,10 +414,10 @@ namespace { // attacked and undefended squares around our king and the quality of // the pawn shelter (current 'score' value). attackUnits = std::min(74, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) - + 8 * ei.kingAdjacentZoneAttacksCount[Them] + + 8 * ei.kingAdjacentZoneAttacksCount[Them] + 25 * popcount(undefended) - + 11 * (ei.pinnedPieces[Us] != 0) - - mg_value(score) * 31 / 256 + + 11 * (ei.pinnedPieces[Us] != 0) + - mg_value(score) / 8 - !pos.count(Them) * 60; // Analyse the enemy's safe queen contact checks. Firstly, find the @@ -547,19 +548,23 @@ namespace { score += more_than_one(b) ? KingOnMany : KingOnOne; } - // Add bonus for safe pawn pushes which attacks an enemy piece + // Add a small bonus for safe pawn pushes b = pos.pieces(Us, PAWN) & ~TRank7BB; b = shift_bb(b | (shift_bb(b & TRank2BB) & ~pos.pieces())); b &= ~pos.pieces() & ~ei.attackedBy[Them][PAWN] - & (ei.attackedBy[Us][PAWN] | ~ei.attackedBy[Them][ALL_PIECES]); + & (ei.attackedBy[Us][ALL_PIECES] | ~ei.attackedBy[Them][ALL_PIECES]); + if (b) + score += popcount(b) * PawnSafePush; + + // Add another bonus if the pawn push attacks an enemy piece b = (shift_bb(b) | shift_bb(b)) & pos.pieces(Them) & ~ei.attackedBy[Us][PAWN]; - if(b) + if (b) score += popcount(b) * PawnAttackThreat; if (Trace) @@ -912,14 +917,14 @@ namespace Eval { void init() { - const double MaxSlope = 8.7; - const double Peak = 1280; - double t = 0.0; + const int MaxSlope = 8700; + const int Peak = 1280000; + int t = 0; - for (int i = 1; i < 400; ++i) + for (int i = 0; i < 400; ++i) { - t = std::min(Peak, std::min(0.027 * i * i, t + MaxSlope)); - KingDanger[i] = apply_weight(make_score(int(t), 0), Weights[KingSafety]); + t = std::min(Peak, std::min(i * i * 27, t + MaxSlope)); + KingDanger[i] = apply_weight(make_score(t / 1000, 0), Weights[KingSafety]); } }