[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:
parent
654e4094d9
commit
164fe94bc0
6 changed files with 190 additions and 73 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue