From ed12bd22248e78ad28157ededfed2be63e2d5062 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 24 Jan 2023 22:34:21 +0300 Subject: refactor: cleanup material advantage calculation --- src/board/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/board/mod.rs') diff --git a/src/board/mod.rs b/src/board/mod.rs index e2d4d60..5e2f4e3 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -44,6 +44,13 @@ pub enum PieceType { KingBlack, } +impl PieceType { + pub fn without_color(&self) -> Self { + let index = *self as usize; + Self::from(index % 6) + } +} + const PIECE_CHARS: [&str; 12] = [ "♟︎", "♞", "♝", "♜", "♛", "♚", "♙", "♘", "♗", "♖", "♕", "♔", @@ -147,10 +154,6 @@ impl Board { occupancy } - pub fn color_to_move(&self) -> Color { - Color::from((self.ply % 2) as u8) - } - pub fn print(&self) { println!(); for rank in (0..8).rev() { -- cgit v1.2.3