From 1ece3c030daebd9fb49870688de73dff10ba6052 Mon Sep 17 00:00:00 2001 From: FauziAkram Date: Thu, 25 Jun 2026 13:07:50 +0200 Subject: [PATCH] Simplify Evasion Logic When the king is in check, a pseudo-legal move must be a valid evasion. Instead of duplicating the checking rules for king and non-king moves, we can leverage the existing MoveList class. Passed non-reg STC: LLR: 2.98 (-2.94,2.94) <-1.75,0.25> Total: 187360 W: 47579 L: 47524 D: 92257 Ptnml(0-2): 418, 20266, 52263, 20309, 424 https://tests.stockfishchess.org/tests/view/6a28aa5b7c758d82accea13c closes https://github.com/official-stockfish/Stockfish/pull/6902 No functional change --- src/position.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index d14385b13..f4477ddf2 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -752,26 +752,8 @@ bool Position::pseudo_legal(const Move m) const { else if (!(attacks_bb(type_of(pc), from, pieces()) & to)) return false; - // Evasions generator already takes care to avoid some kind of illegal moves - // and legal() relies on this. We therefore have to take care that the same - // kind of moves are filtered out here. if (checkers()) - { - if (type_of(pc) != KING) - { - // Double check? In this case, a king move is required - if (more_than_one(checkers())) - return false; - - // Our move must be a blocking interposition or a capture of the checking piece - if (!(between_bb(square(us), lsb(checkers())) & to)) - return false; - } - // In case of king moves under check we have to remove the king so as to catch - // invalid moves like b1a1 when opposite queen is on c1. - else if (attackers_to_exist(to, pieces() ^ from, ~us)) - return false; - } + return MoveList(*this).contains(m); return true; }