From 587378bc98797ae0b7d8befbd0da1543e138d973 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 26 Jan 2023 19:28:16 +0300 Subject: fix: correctly check empty castle line --- src/board/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/board') diff --git a/src/board/mod.rs b/src/board/mod.rs index cce2ca7..76ebd59 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -322,7 +322,7 @@ impl Board { king_home_position.west_one().west_one(), ]; - let all_empty = castle_line.iter().all(|square| empty & square.to_bitboard() > 0); + let all_empty = castle_line.iter().skip(1).all(|square| empty & square.to_bitboard() > 0); let any_checks = castle_line.iter().any(|square| self.is_square_attacked(*square, color.flip())); if all_empty && !any_checks && self.castling_rights[color as usize][CastlingSide::Queen as usize] { @@ -340,7 +340,7 @@ impl Board { king_home_position.east_one().east_one(), ]; - let all_empty = castle_line.iter().all(|square| empty & square.to_bitboard() > 0); + let all_empty = castle_line.iter().skip(1).all(|square| empty & square.to_bitboard() > 0); let any_checks = castle_line.iter().any(|square| self.is_square_attacked(*square, color.flip())); if all_empty && !any_checks && self.castling_rights[color as usize][CastlingSide::King as usize] { -- cgit v1.2.3