diff --git a/src/logic/board_value.rs b/src/logic/board_value.rs index 7c4bf6f..4c97690 100644 --- a/src/logic/board_value.rs +++ b/src/logic/board_value.rs @@ -1,9 +1,9 @@ use crate::repr::{Board, Piece, PosMap}; -pub struct BoardValueMap(PosMap); +pub struct BoardValueMap(PosMap); impl BoardValueMap { - pub fn board_value(&self, board: &Board, color: Piece) -> i64 { + pub fn board_value(&self, board: &Board, color: Piece) -> i16 { Board::all_positions() .filter_map(|coord| board.get(coord).map(|p| (coord, p))) .map(|(coord, pos_p)| (*self.0.get(coord), pos_p)) @@ -20,7 +20,7 @@ impl BoardValueMap { /// Weights from: https://repub.eur.nl/pub/7142/ei2005-47.pdf pub fn new() -> Self { - const POSITION_VALUES: [[i64; 8]; 8] = [ + const POSITION_VALUES: [[i16; 8]; 8] = [ [100, -20, 10, 5, 5, 10, -20, 100], [-20, -50, -2, -2, -2, -2, -50, -20], [10, -2, -1, -1, -1, -1, -2, 10], diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index f225ce7..f3ee325 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -277,8 +277,8 @@ impl FutureMoves { let children_value = match self.config.children_eval_method { ChildrenEvalMethod::Average => children_values .into_iter() - .sum::() - .checked_div(self.arena[idx].children.len() as i128), + .sum::() + .checked_div(self.arena[idx].children.len() as i32), ChildrenEvalMethod::Max => children_values.into_iter().max(), ChildrenEvalMethod::Min => children_values.into_iter().min(), } @@ -288,7 +288,7 @@ impl FutureMoves { // we should really setup some sort of ELO rating for each commit, playing them against // each other or something, could be cool to benchmark these more subjective things, not // just performance (cycles/time wise) - self.arena[idx].value = Some(self.arena[idx].self_value as i128 + children_value); + self.arena[idx].value = Some(self.arena[idx].self_value as i32 + children_value); } } } diff --git a/src/logic/move.rs b/src/logic/move.rs index 2f98d7f..c5ec2b9 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -23,10 +23,10 @@ pub struct Move { pub tried_children: bool, /// Value of this move (including children) - pub value: Option, + pub value: Option, /// What is the inherit value of this move (not including children) - pub self_value: i64, + pub self_value: i16, /// Which color made a move on this move? pub color: Piece, @@ -55,15 +55,15 @@ impl Move { m } - fn compute_self_value(&self, agent_color: Piece) -> i64 { + fn compute_self_value(&self, agent_color: Piece) -> i16 { if self.winner == Winner::Player(!agent_color) { // if this board results in the opponent winning, MAJORLY negatively weigh this move // NOTE! this branch isn't completely deleted because if so, the bot wouldn't make a move. // We shouldn't prune branches because we still need to always react to the opponent's moves - return i64::MIN + 1; + return i16::MIN + 1; } else if self.winner == Winner::Player(agent_color) { // results in a win for the agent - return i64::MAX - 1; + return i16::MAX - 1; } // else if self.winner == Winner::Tie { // // idk what a Tie should be valued?