|
|
|
|
@ -366,7 +366,7 @@ impl Board {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Capture the intened move in the moves ledger
|
|
|
|
|
// Capture the intended move in the moves ledger
|
|
|
|
|
moves.push(Move {
|
|
|
|
|
epoch,
|
|
|
|
|
from,
|
|
|
|
|
@ -419,8 +419,8 @@ impl Board {
|
|
|
|
|
let valid_capture = {
|
|
|
|
|
match self.at(this_board_index) {
|
|
|
|
|
Some(_) => {
|
|
|
|
|
let same_side = Board::side(current_board_index);
|
|
|
|
|
Board::side(this_board_index) != same_side
|
|
|
|
|
Board::side(this_board_index)
|
|
|
|
|
!= Board::side(current_board_index)
|
|
|
|
|
}
|
|
|
|
|
None => true,
|
|
|
|
|
}
|
|
|
|
|
@ -478,9 +478,31 @@ impl Board {
|
|
|
|
|
.collect(),
|
|
|
|
|
// One or two spaces in either horizontal
|
|
|
|
|
Some(Piece::Drone) => std::iter::empty()
|
|
|
|
|
.chain((-2..=2).map(|i| (x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.chain((-2..=2).map(|i| (Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.filter_map(f)
|
|
|
|
|
// Checking moves on the X axis
|
|
|
|
|
.chain(
|
|
|
|
|
(-2..=-1)
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.rev()
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(1..=2)
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
// Checking moves on the Y axis
|
|
|
|
|
.chain(
|
|
|
|
|
(1..=2)
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(-2..=-1)
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.rev()
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.filter_map(|x| x)
|
|
|
|
|
.collect(),
|
|
|
|
|
// Any distance in any straight line
|
|
|
|
|
Some(Piece::Queen) => std::iter::empty()
|
|
|
|
|
|