diff --git a/src/movepick.cpp b/src/movepick.cpp index dd6d71167..0d2a72306 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -129,13 +129,15 @@ ExtMove* MovePicker::score(MoveList& ml) { Color us = pos.side_to_move(); - [[maybe_unused]] Bitboard threatByLesser[QUEEN + 1]; + [[maybe_unused]] Bitboard threatByLesser[KING + 1]; if constexpr (Type == QUIETS) { + threatByLesser[PAWN] = 0; threatByLesser[KNIGHT] = threatByLesser[BISHOP] = pos.attacks_by(~us); threatByLesser[ROOK] = pos.attacks_by(~us) | pos.attacks_by(~us) | threatByLesser[KNIGHT]; threatByLesser[QUEEN] = pos.attacks_by(~us) | threatByLesser[ROOK]; + threatByLesser[KING] = pos.attacks_by(~us) | threatByLesser[QUEEN]; } ExtMove* it = cur; @@ -170,12 +172,10 @@ ExtMove* MovePicker::score(MoveList& ml) { // penalty for moving to a square threatened by a lesser piece // or bonus for escaping an attack by a lesser piece. - if (KNIGHT <= pt && pt <= QUEEN) - { - static constexpr int bonus[QUEEN + 1] = {0, 0, 144, 144, 256, 517}; - int v = threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from); - m.value += bonus[pt] * v; - } + static constexpr int bonus[KING + 1] = {0, 0, 144, 144, 256, 517, 10000}; + int v = threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from); + m.value += bonus[pt] * v; + if (ply < LOW_PLY_HISTORY_SIZE) m.value += 8 * (*lowPlyHistory)[ply][m.from_to()] / (1 + ply);