X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=031b803417c4c4832f7b6fe5bdb2a3d26618f724;hb=c33af32dada1be9f6aed851e8cf87599203e2eb2;hp=d47c0955a5d60a90f465dbd6cd1d5e83139b379e;hpb=6d24ef8585c2ed5618eb9b4ab1d8ee35a05ce2cd;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d47c0955..031b8034 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -78,7 +78,7 @@ namespace { public: Evaluation() = delete; - Evaluation(const Position& p) : pos(p) {}; + Evaluation(const Position& p) : pos(p) {} Evaluation& operator=(const Evaluation&) = delete; Value value(); @@ -162,8 +162,8 @@ namespace { // supported by a pawn. If the minor piece occupies an outpost square // then score is doubled. const Score Outpost[][2] = { - { S(22, 6), S(33, 9) }, // Knight - { S( 9, 2), S(14, 4) } // Bishop + { S(22, 6), S(36,12) }, // Knight + { S( 9, 2), S(15, 5) } // Bishop }; // RookOnFile[semiopen/open] contains bonuses for each rook when there is no @@ -214,13 +214,10 @@ namespace { const Score ThreatBySafePawn = S(182,175); const Score ThreatByRank = S( 16, 3); const Score Hanging = S( 48, 27); + const Score WeakUnopposedPawn = S( 5, 25); const Score ThreatByPawnPush = S( 38, 22); const Score HinderPassedPawn = S( 7, 0); - - // 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 - // happen in Chess960 games. - const Score TrappedBishopA1H1 = S(50, 50); + const Score TrappedBishopA1H1 = S( 50, 50); #undef S #undef V @@ -412,11 +409,11 @@ namespace { const Color Them = (Us == WHITE ? BLACK : WHITE); const Square Up = (Us == WHITE ? NORTH : SOUTH); - const Bitboard Camp = (Us == WHITE ? ~Bitboard(0) ^ Rank6BB ^ Rank7BB ^ Rank8BB - : ~Bitboard(0) ^ Rank1BB ^ Rank2BB ^ Rank3BB); + const Bitboard Camp = (Us == WHITE ? AllSquares ^ Rank6BB ^ Rank7BB ^ Rank8BB + : AllSquares ^ Rank1BB ^ Rank2BB ^ Rank3BB); const Square ksq = pos.square(Us); - Bitboard kingOnlyDefended, b, b1, b2, safe, other; + Bitboard kingOnlyDefended, undefended, b, b1, b2, safe, other; int kingDanger; // King shelter and enemy pawns storm @@ -431,8 +428,10 @@ namespace { & ~attackedBy2[Us]; // ... and those which are not defended at all in the larger king ring - b = attackedBy[Them][ALL_PIECES] & ~attackedBy[Us][ALL_PIECES] - & kingRing[Us] & ~pos.pieces(Them); + undefended = attackedBy[Them][ALL_PIECES] + & ~attackedBy[Us][ALL_PIECES] + & kingRing[Us] + & ~pos.pieces(Them); // Initialize the 'kingDanger' variable, which will be transformed // later into a king danger score. The initial value is based on the @@ -441,8 +440,8 @@ namespace { // the quality of the pawn shelter (current 'score' value). kingDanger = kingAttackersCount[Them] * kingAttackersWeight[Them] + 102 * kingAdjacentZoneAttacksCount[Them] - + 201 * popcount(kingOnlyDefended) - + 143 * (popcount(b) + !!pos.pinned_pieces(Us)) + + 191 * popcount(kingOnlyDefended | undefended) + + 143 * !!pos.pinned_pieces(Us) - 848 * !pos.count(Them) - 9 * mg_value(score) / 8 + 40; @@ -595,6 +594,10 @@ namespace { score += ThreatByKing[more_than_one(b)]; } + // Bonus for opponent unopposed weak pawns + if (pos.pieces(Us, ROOK, QUEEN)) + score += WeakUnopposedPawn * pe->weak_unopposed(Them); + // Find squares where our pawns can push on the next move b = shift(pos.pieces(Us, PAWN)) & ~pos.pieces(); b |= shift(b & TRank3BB) & ~pos.pieces();