X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=da90eed974e81a4c80780fc4bb953432cee20914;hb=3f7ec977cdae7a59c58342f3752bccb293d4e206;hp=5b914d879652861b38dd03b39d7fd9c1a6f4af3d;hpb=691a287bfe7a2afbfa1d2b3129f4a089b188b6e4;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 5b914d87..da90eed9 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -93,8 +93,8 @@ namespace { // Penalties for enemy's safe checks constexpr int QueenSafeCheck = 780; - constexpr int RookSafeCheck = 880; - constexpr int BishopSafeCheck = 435; + constexpr int RookSafeCheck = 1080; + constexpr int BishopSafeCheck = 635; constexpr int KnightSafeCheck = 790; #define S(mg, eg) make_score(mg, eg) @@ -168,7 +168,7 @@ namespace { constexpr Score ThreatByPawnPush = S( 48, 39); constexpr Score ThreatByRank = S( 13, 0); constexpr Score ThreatBySafePawn = S(173, 94); - constexpr Score TrappedRook = S( 96, 4); + constexpr Score TrappedRook = S( 47, 4); constexpr Score WeakQueen = S( 49, 15); constexpr Score WeakUnopposedPawn = S( 12, 23); @@ -377,7 +377,7 @@ namespace { { File kf = file_of(pos.square(Us)); if ((kf < FILE_E) == (file_of(s) < kf)) - score -= (TrappedRook - make_score(mob * 22, 0)) * (1 + !pos.castling_rights(Us)); + score -= TrappedRook * (1 + !pos.castling_rights(Us)); } } @@ -434,27 +434,42 @@ namespace { b1 = attacks_bb(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN)); b2 = attacks_bb(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN)); - // Enemy queen safe checks - if ((b1 | b2) & attackedBy[Them][QUEEN] & safe & ~attackedBy[Us][QUEEN]) - kingDanger += QueenSafeCheck; - - b1 &= attackedBy[Them][ROOK]; - b2 &= attackedBy[Them][BISHOP]; - // Enemy rooks checks - if (b1 & safe) + Bitboard RookCheck = b1 + & safe + & attackedBy[Them][ROOK]; + + if (RookCheck) kingDanger += RookSafeCheck; else - unsafeChecks |= b1; + unsafeChecks |= b1 & attackedBy[Them][ROOK]; + + // Enemy queen safe checks: we count them only if they are from squares from + // which we can't give a rook check, because rook checks are more valuable. + Bitboard QueenCheck = (b1 | b2) + & attackedBy[Them][QUEEN] + & safe + & ~attackedBy[Us][QUEEN] + & ~RookCheck; - // Enemy bishops checks - if (b2 & safe) + if (QueenCheck) + kingDanger += QueenSafeCheck; + + // Enemy bishops checks: we count them only if they are from squares from + // which we can't give a queen check, because queen checks are more valuable. + Bitboard BishopCheck = b2 + & attackedBy[Them][BISHOP] + & safe + & ~QueenCheck; + + if (BishopCheck) kingDanger += BishopSafeCheck; else - unsafeChecks |= b2; + unsafeChecks |= b2 & attackedBy[Them][BISHOP]; // Enemy knights checks b = pos.attacks_from(ksq) & attackedBy[Them][KNIGHT]; + if (b & safe) kingDanger += KnightSafeCheck; else