diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 05:57:35 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 06:50:00 +0300 |
commit | 87e7b1341647bf24c21771c9fa5be5ff10e97e73 (patch) | |
tree | 4282d2e8989e29daefd8c193b3da18718a13c535 /src/board | |
parent | 3522398f7a456b400dc48de4c202a013490cd4fc (diff) | |
download | chessnost-87e7b1341647bf24c21771c9fa5be5ff10e97e73.tar.gz |
refactor: impl static_eval for PieceType
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/engine.rs | 13 | ||||
-rw-r--r-- | src/board/mod.rs | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index fb06fa4..f7139e5 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -87,16 +87,7 @@ impl Board { } else { -1. }; - let multiplier = match piece_type.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"), - }; - + let multiplier = piece_type.static_eval(); eval += sign * multiplier * pop_count(*bitboard) as f32; } eval @@ -124,9 +115,9 @@ impl Board { let moves = match transposition { Some(item) => { - // println!("Cache hit! {:?}", item); if item.node_type == NodeType::PV && item.depth >= depth_left { + // println!("Cache hit (depth_left={}): {:?}", depth_left, item); vec![item.best_move] } else { self.generate_pseudolegal_moves(color) 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] = [ |