X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=fe4eef57493c8ed3a601120dc7fee3233e7a1b5d;hp=5a8a292f9a24c34596309562f6c86c79a29fb4c0;hb=0958e5c6d346d1fac5fbae5e12762a48c6d24a2a;hpb=43f67eab5f55508e07e4e3d7cec885dc4e82036f diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 5a8a292f..fe4eef57 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -642,31 +642,19 @@ Value do_evaluate(const Position& pos, Value& margin) { score += RookHalfOpenFileBonus; } - // Penalize rooks which are trapped inside a king. Penalize more if - // king has lost right to castle. if (mob > 6 || ei.pi->file_is_half_open(Us, f)) continue; ksq = pos.king_square(Us); - if ( file_of(ksq) >= FILE_E - && file_of(s) > file_of(ksq) - && (relative_rank(Us, ksq) == RANK_1 || rank_of(ksq) == rank_of(s))) - { - // Is there a half-open file between the king and the edge of the board? - if (!ei.pi->has_open_file_to_right(Us, file_of(ksq))) - score -= make_score(pos.can_castle(Us) ? (TrappedRookPenalty - mob * 16) / 2 - : (TrappedRookPenalty - mob * 16), 0); - } - else if ( file_of(ksq) <= FILE_D - && file_of(s) < file_of(ksq) - && (relative_rank(Us, ksq) == RANK_1 || rank_of(ksq) == rank_of(s))) - { - // Is there a half-open file between the king and the edge of the board? - if (!ei.pi->has_open_file_to_left(Us, file_of(ksq))) - score -= make_score(pos.can_castle(Us) ? (TrappedRookPenalty - mob * 16) / 2 - : (TrappedRookPenalty - mob * 16), 0); - } + // Penalize rooks which are trapped inside a king. Penalize more if + // king has lost right to castle. + if ( ((file_of(ksq) < FILE_E) == (file_of(s) < file_of(ksq))) + && rank_of(ksq) == rank_of(s) + && relative_rank(Us, ksq) == RANK_1 + && !ei.pi->has_open_file_on_side(Us, file_of(ksq), file_of(ksq) < FILE_E)) + score -= make_score(pos.can_castle(Us) ? (TrappedRookPenalty - mob * 16) / 2 + : (TrappedRookPenalty - mob * 16), 0); } }