aboutsummaryrefslogtreecommitdiff
path: root/src/board/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/board/mod.rs')
-rw-r--r--src/board/mod.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/board/mod.rs b/src/board/mod.rs
index 76ebd59..589da8a 100644
--- a/src/board/mod.rs
+++ b/src/board/mod.rs
@@ -316,14 +316,18 @@ impl Board {
{
match rook_square.file() {
0 => {
- let castle_line = [
- king_home_position,
+ let all_empty = [
king_home_position.west_one(),
king_home_position.west_one().west_one(),
- ];
+ king_home_position.west_one().west_one().west_one(),
- 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()));
+ ].iter().all(|square| empty & square.to_bitboard() > 0);
+
+ let any_checks = [
+ king_home_position,
+ king_home_position.west_one(),
+ king_home_position.west_one().west_one(),
+ ].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] {
moves.push(Move {
@@ -334,14 +338,17 @@ impl Board {
}
},
7 => {
- let castle_line = [
- king_home_position,
+ let all_empty = [
king_home_position.east_one(),
king_home_position.east_one().east_one(),
- ];
- 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()));
+ ].iter().all(|square| empty & square.to_bitboard() > 0);
+
+ let any_checks = [
+ king_home_position,
+ king_home_position.east_one(),
+ king_home_position.east_one().east_one(),
+ ].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] {
moves.push(Move {