From 87e7b1341647bf24c21771c9fa5be5ff10e97e73 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 25 Jan 2023 05:57:35 +0300 Subject: refactor: impl static_eval for PieceType --- src/board/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/board/mod.rs') diff --git a/src/board/mod.rs b/src/board/mod.rs index 2ff7f9c..61327eb 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -58,6 +58,18 @@ impl PieceType { 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() { + PieceType::Pawn => 1., + PieceType::Bishop => 3., + PieceType::Knight => 3., + PieceType::Rook => 4.5, + PieceType::Queen => 9., + PieceType::King => 0., + _ => panic!("Piece should be without color"), + } + } } const PIECE_CHARS: [&str; 12] = [ -- cgit v1.2.3