The moves command writes all possible moves to the terminal. Move the previous implementation of the moves command, which marked squares that a piece could move to, to a 'movement' command.
43 lines
865 B
Rust
43 lines
865 B
Rust
// Eryn Wells <eryn@erynwells.me>
|
|
|
|
mod all;
|
|
mod king;
|
|
mod knight;
|
|
mod pawn;
|
|
mod slider;
|
|
|
|
#[cfg(test)]
|
|
mod testing;
|
|
|
|
pub use all::AllPiecesMoveGenerator;
|
|
pub use king::KingMoveGenerator;
|
|
pub use knight::KnightMoveGenerator;
|
|
pub use pawn::PawnMoveGenerator;
|
|
pub use slider::{BishopMoveGenerator, QueenMoveGenerator, RookMoveGenerator};
|
|
|
|
use crate::Move;
|
|
use chessfriend_core::Square;
|
|
|
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
|
pub struct GeneratedMove {
|
|
pub(crate) ply: Move,
|
|
}
|
|
|
|
impl GeneratedMove {
|
|
#[must_use]
|
|
pub fn origin(&self) -> Square {
|
|
self.ply.origin_square()
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for GeneratedMove {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
self.ply.fmt(f)
|
|
}
|
|
}
|
|
|
|
impl From<Move> for GeneratedMove {
|
|
fn from(value: Move) -> Self {
|
|
GeneratedMove { ply: value }
|
|
}
|
|
}
|