[board] Implement danger squares for the current player

This concept comes from [1]. Danger squares are the squares a king cannot move to
because it would permit the opposing player to capture the king on their next
turn.

[1]: https://peterellisjones.com/posts/generating-legal-chess-moves-efficiently/
This commit is contained in:
Eryn Wells 2024-01-28 00:25:53 -08:00
parent 654e4094d9
commit 164fe94bc0
6 changed files with 190 additions and 73 deletions

View file

@ -14,17 +14,17 @@ pub enum Shape {
}
impl Shape {
pub fn iter() -> Iter<'static, Shape> {
const ALL_SHAPES: [Shape; 6] = [
Shape::Pawn,
Shape::Knight,
Shape::Bishop,
Shape::Rook,
Shape::Queen,
Shape::King,
];
pub const ALL: [Shape; 6] = [
Shape::Pawn,
Shape::Knight,
Shape::Bishop,
Shape::Rook,
Shape::Queen,
Shape::King,
];
ALL_SHAPES.iter()
pub fn iter() -> Iter<'static, Shape> {
Shape::ALL.iter()
}
pub fn promotable() -> Iter<'static, Shape> {