diff options
Diffstat (limited to 'src/board/piece.rs')
-rw-r--r-- | src/board/piece.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/board/piece.rs b/src/board/piece.rs new file mode 100644 index 0000000..1889e94 --- /dev/null +++ b/src/board/piece.rs @@ -0,0 +1,36 @@ +#[derive(Debug, Clone, Copy, PartialEq, Eq, num_enum::FromPrimitive)] +#[repr(usize)] +pub enum Piece { + #[default] + Pawn, + Knight, + Bishop, + Rook, + Queen, + King, + PawnBlack, + KnightBlack, + BishopBlack, + RookBlack, + QueenBlack, + KingBlack, +} + +impl Piece { + pub fn without_color(&self) -> Self { + let index = *self as usize; + Self::from(index % 6) + } + // Return the price of the peice + pub fn static_eval(&self) -> f32 { + match self.without_color() { + Piece::Pawn => 1.0, + Piece::Bishop => 3.3, + Piece::Knight => 3.2, + Piece::Rook => 5.0, + Piece::Queen => 9.0, + Piece::King => 0., + _ => panic!("Piece should be without color"), + } + } +} |