WIP
This commit is contained in:
parent
d5cdf273c8
commit
091cc99cb3
42 changed files with 805 additions and 1662 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
use chessfriend_core::Shape;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub(crate) enum Kind {
|
||||
Quiet = 0b0000,
|
||||
DoublePush = 0b0001,
|
||||
|
@ -13,6 +14,12 @@ pub(crate) enum Kind {
|
|||
CapturePromotion = 0b1100,
|
||||
}
|
||||
|
||||
impl Kind {
|
||||
fn is_reversible(self) -> bool {
|
||||
(self as u16) & 0b1100 == 0
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u16)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum PromotionShape {
|
||||
|
@ -32,3 +39,17 @@ impl From<PromotionShape> for Shape {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Shape> for PromotionShape {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: Shape) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
Shape::Knight => Ok(PromotionShape::Knight),
|
||||
Shape::Bishop => Ok(PromotionShape::Bishop),
|
||||
Shape::Rook => Ok(PromotionShape::Rook),
|
||||
Shape::Queen => Ok(PromotionShape::Queen),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue