Fix updating gates on castling move
authorgbtami <gbtami@gmail.com>
Wed, 7 Aug 2019 11:58:05 +0000 (13:58 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Wed, 7 Aug 2019 15:11:03 +0000 (17:11 +0200)
src/position.cpp

index def94c0..1eede29 100644 (file)
@@ -1296,8 +1296,8 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
   {
       if (is_ok(from) && (gates(us) & from))
           st->gatesBB[us] ^= from;
-      if (type_of(m) == CASTLING)
-          st->gatesBB[us] ^= to;
+      if (type_of(m) == CASTLING && (gates(us) & to_sq(m)))
+          st->gatesBB[us] ^= to_sq(m);
       if (gates(them) & to)
           st->gatesBB[them] ^= to;
       if (!count_in_hand(us, ALL_PIECES) && !captures_to_hand())