File size: 827 Bytes
d7ecc62 | 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 37 38 39 40 | /// Termination reasons for a chess game.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum Termination {
Checkmate = 0,
Stalemate = 1,
SeventyFiveMoveRule = 2,
FivefoldRepetition = 3,
InsufficientMaterial = 4,
PlyLimit = 5,
}
impl Termination {
pub fn as_u8(self) -> u8 {
self as u8
}
}
/// Promotion piece types in our vocabulary order: q=0, r=1, b=2, n=3.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum PromoType {
Queen = 0,
Rook = 1,
Bishop = 2,
Knight = 3,
}
impl PromoType {
pub fn from_index(i: u8) -> Option<Self> {
match i {
0 => Some(Self::Queen),
1 => Some(Self::Rook),
2 => Some(Self::Bishop),
3 => Some(Self::Knight),
_ => None,
}
}
}
|