From a255ad59e3ab9bc0e806954e1ee0205da13b4030 Mon Sep 17 00:00:00 2001 From: mstembera <5421953+mstembera@users.noreply.github.com> Date: Thu, 16 Jul 2026 08:18:06 +0200 Subject: [PATCH] Optimize evasions in Position::pseudo_legal() STC: https://tests.stockfishchess.org/tests/view/6a4be17d5529b8472df7fa60 LLR: 3.68 (-2.94,2.94) <0.00,2.00> Total: 405888 W: 105701 L: 104837 D: 195350 Ptnml(0-2): 872, 42472, 115373, 43374, 853 closes https://github.com/official-stockfish/Stockfish/pull/6968 No functional change --- src/position.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 4279f89d4..42bb871a4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -745,8 +745,16 @@ bool Position::pseudo_legal(const Move m) const { else if (!(attacks_bb(type_of(pc), from, pieces()) & to)) return false; - if (checkers()) - return MoveList(*this).contains(m); + if (checkers() && type_of(pc) != KING) + { + // In double check, only a king move can evade + if (more_than_one(checkers())) + return false; + + // The move must block the check or capture the checker + if (!(between_bb(square(us), lsb(checkers())) & to)) + return false; + } return true; }