Queen "no jumping" is _mostly_ implemented.

You can still jump over enemies which is BS.
That is going to require some... magic... to fix.
main
Elijah C. Voigt 2 years ago
parent 0edfcfec5b
commit f0befe0928

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

Loading…
Cancel
Save