use super::color::Color; #[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) } /// Note: assumes self is without color! pub fn colored(&self, color: Color) -> Self { match color { Color::White => *self, Color::Black => Self::from(*self as usize + 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"), } } }