]> git.sesse.net Git - stockfish/commitdiff
simplified gives check castling
authorrn5f107s2 <clemens.lerchl@gmail.com>
Fri, 16 Jun 2023 16:49:31 +0000 (18:49 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Mon, 3 Jul 2023 16:54:22 +0000 (18:54 +0200)
tested verifying perft and bench is unchanged
on a larger set of epds for both standard and FRC chess.

Passed non-regression STC:
https://tests.stockfishchess.org/tests/live_elo/648587be65ffe077ca123d78
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 153632 W: 41015 L: 40928 D: 71689
Ptnml(0-2): 377, 16077, 43816, 16174, 372

closes https://github.com/official-stockfish/Stockfish/pull/4628

No functional change

AUTHORS
src/position.cpp

diff --git a/AUTHORS b/AUTHORS
index 2e9ae7805fd553bd0b7a4a5adb3b1b314fb6c343..792893944c42e8d9fbba47b1c76a853edf84065d 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -179,6 +179,7 @@ Raminder Singh
 renouve
 Reuven Peleg (R-Peleg)
 Richard Lloyd (Richard-Lloyd)
+rn5f107s2
 Rodrigo Exterckötter Tjäder
 Rodrigo Roim (roim)
 Ronald de Man (syzygy1, syzygy)
index 2a9d798ff7d0d85afa60c75f35646b7e4b399ef6..a052cf32f03dc6d21a56f0f2b2b8dd2e59a3f6a0 100644 (file)
@@ -638,9 +638,9 @@ bool Position::gives_check(Move m) const {
       return true;
 
   // Is there a discovered check?
-  if (   (blockers_for_king(~sideToMove) & from)
-      && !aligned(from, to, square<KING>(~sideToMove)))
-      return true;
+  if (blockers_for_king(~sideToMove) & from)
+      return   !aligned(from, to, square<KING>(~sideToMove))
+            || type_of(m) == CASTLING;
 
   switch (type_of(m))
   {
@@ -665,11 +665,9 @@ bool Position::gives_check(Move m) const {
   default: //CASTLING
   {
       // Castling is encoded as 'king captures the rook'
-      Square ksq = square<KING>(~sideToMove);
       Square rto = relative_square(sideToMove, to > from ? SQ_F1 : SQ_D1);
 
-      return   (attacks_bb<ROOK>(rto) & ksq)
-            && (attacks_bb<ROOK>(rto, pieces() ^ from ^ to) & ksq);
+      return check_squares(ROOK) & rto;
   }
   }
 }