Specify move type using new MoveType enum and update tests
This commit is contained in:
46
src/move.rs
Normal file
46
src/move.rs
Normal 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 {}
|
||||
Reference in New Issue
Block a user