diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-26 19:28:16 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-26 19:28:16 +0300 |
commit | 587378bc98797ae0b7d8befbd0da1543e138d973 (patch) | |
tree | b27747c5a96d45f0de6c971163726735616d233d /src/board | |
parent | ba7d370ffbae459782b5356b4a4364ac94c378f2 (diff) | |
download | chessnost-587378bc98797ae0b7d8befbd0da1543e138d973.tar.gz |
fix: correctly check empty castle line
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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] { |