X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=108f6c8a39e68bf74370b437a1a52b3d58182ff9;hp=e861f5f032e95d80f54bb4137447e617686b338b;hb=3b92159908e7026683d5a6090b7a2d7fb41e97a5;hpb=79bcb2ca54aa72bd9e3d1ba1ed1dcb2a4ddf14c9 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index e861f5f0..108f6c8a 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -648,25 +648,13 @@ Value do_evaluate(const Position& pos, Value& margin) { continue; ksq = pos.king_square(Us); + bool left = file_of(ksq) < FILE_E; - 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); - } + if ( ((left && file_of(s) < file_of(ksq)) || (!left && file_of(s) > file_of(ksq))) + && (relative_rank(Us, ksq) == RANK_1 || rank_of(ksq) == rank_of(s)) + && (!ei.pi->has_open_file_on_side(Us, file_of(ksq), left))) + score -= make_score(pos.can_castle(Us) ? (TrappedRookPenalty - mob * 16) / 2 + : (TrappedRookPenalty - mob * 16), 0); } } @@ -730,7 +718,7 @@ Value do_evaluate(const Position& pos, Value& margin) { Score score = mobility = SCORE_ZERO; // Do not include in mobility squares protected by enemy pawns or occupied by our pieces - const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces(Us)); + const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces(Us, PAWN, KING)); score += evaluate_pieces(pos, ei, mobility, mobilityArea); score += evaluate_pieces(pos, ei, mobility, mobilityArea);