1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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"),
}
}
}
|