|
|
|
|
@ -481,8 +481,8 @@ impl Board {
|
|
|
|
|
// Checking moves on the X axis
|
|
|
|
|
.chain(
|
|
|
|
|
(-2..=-1)
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.rev()
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
@ -498,27 +498,63 @@ impl Board {
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(-2..=-1)
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.rev()
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.filter_map(|x| x)
|
|
|
|
|
.collect(),
|
|
|
|
|
// Any distance in any straight line
|
|
|
|
|
Some(Piece::Queen) => std::iter::empty()
|
|
|
|
|
.chain((-7..=7).map(|i| (x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.chain((-3..=3).map(|i| (Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.chain(
|
|
|
|
|
(-3..=3)
|
|
|
|
|
.zip(-3..=3)
|
|
|
|
|
.map(move |(a, b)| (x.checked_add_signed(a), y.checked_add_signed(b))),
|
|
|
|
|
(-7..=-1)
|
|
|
|
|
.rev()
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(-3..=3)
|
|
|
|
|
.zip((-3..=3).rev())
|
|
|
|
|
.map(move |(a, b)| (x.checked_add_signed(a), y.checked_add_signed(b))),
|
|
|
|
|
(1..=7)
|
|
|
|
|
.map(|i| f((x.checked_add_signed(i), Some(y))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.filter_map(f)
|
|
|
|
|
.chain(
|
|
|
|
|
(-3..=-1)
|
|
|
|
|
.rev()
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(1..=3)
|
|
|
|
|
.map(|i| f((Some(x), y.checked_add_signed(i))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(-3..=-1)
|
|
|
|
|
.rev()
|
|
|
|
|
.zip((-3..=-1).rev())
|
|
|
|
|
.map(move |(a, b)| f((x.checked_add_signed(a), y.checked_add_signed(b))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(-3..=-1)
|
|
|
|
|
.rev()
|
|
|
|
|
.zip(1..=3)
|
|
|
|
|
.map(move |(a, b)| f((x.checked_add_signed(a), y.checked_add_signed(b))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(1..=3)
|
|
|
|
|
.zip((-3..=-1).rev())
|
|
|
|
|
.map(move |(a, b)| f((x.checked_add_signed(a), y.checked_add_signed(b))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.chain(
|
|
|
|
|
(1..=3)
|
|
|
|
|
.zip(1..=3)
|
|
|
|
|
.map(move |(a, b)| f((x.checked_add_signed(a), y.checked_add_signed(b))))
|
|
|
|
|
.take_while(|x| x.is_some()),
|
|
|
|
|
)
|
|
|
|
|
.filter_map(|x| x)
|
|
|
|
|
.collect(),
|
|
|
|
|
None => std::iter::empty().collect(),
|
|
|
|
|
}
|
|
|
|
|
|