chessfriend/moves/src/generators.rs
Eryn Wells 942d9fe47b [explorer, moves, position] Implement a moves command in explorer
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.
2025-05-28 16:25:55 -07:00

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 }
}
}