X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=db08b1c49e22179fee74b556741104ec3c5d1567;hb=dd8a07612843f32d4073135fc9e17b8814aa34a5;hp=1c215dc0d4a19b586189676331751e7e43845c9b;hpb=4350d9e8a6c979c5631d05ecb645834882701e4c;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 1c215dc0..db08b1c4 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -200,6 +200,7 @@ namespace { // Bonuses for enemy's safe checks const int QueenContactCheckBonus = 6; + const int RookContactCheckBonus = 4; const int QueenCheckBonus = 3; const int RookCheckBonus = 2; const int BishopCheckBonus = 1; @@ -710,6 +711,24 @@ namespace { * (Them == pos.side_to_move() ? 2 : 1); } + // Analyse enemy's safe rook contact checks. First find undefended + // squares around the king attacked by enemy rooks... + b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces_of_color(Them); + + // Consider only squares where the enemy rook gives check + b &= RookPseudoAttacks[ksq]; + + if (b) + { + // ...then remove squares not supported by another enemy piece + b &= ( ei.attackedBy[Them][PAWN] | ei.attackedBy[Them][KNIGHT] + | ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][QUEEN]); + if (b) + attackUnits += RookContactCheckBonus + * count_1s_max_15(b) + * (Them == pos.side_to_move() ? 2 : 1); + } + // Analyse enemy's safe distance checks for sliders and knights safe = ~(pos.pieces_of_color(Them) | ei.attackedBy[Us][0]);