Specify move type using new MoveType enum and update tests

This commit is contained in:
2024-06-29 16:35:49 +03:00
parent f3b2aabf46
commit a514431e7e
4 changed files with 220 additions and 73 deletions

46
src/move.rs Normal file
View File

@@ -0,0 +1,46 @@
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub enum Promote {
Knight,
Rook,
Bishop,
Queen,
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub enum MoveType {
Quiet,
Capture,
DoublePush,
Promotion(Promote),
PromotionCapture(Promote),
EnPassant,
Castle,
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub struct Move {
pub source: u32,
pub target: u32,
pub move_type: MoveType,
}
impl Move {
pub const fn new(source: u32, target: u32) -> Self {
Self {
source,
target,
move_type: MoveType::Quiet,
}
}
pub const fn new_with_type(source: u32, target: u32, move_type: MoveType) -> Self {
Self {
source,
target,
move_type,
}
}
}
#[cfg(test)]
mod tests {}