diff --git a/src/elo.rs b/src/elo.rs index 9a1e2b9..0303113 100644 --- a/src/elo.rs +++ b/src/elo.rs @@ -71,11 +71,9 @@ pub fn run() { .to_vec() }) .flat_map(move |prev_c| { - [ChildrenEvalMethod::MinMax, ChildrenEvalMethod::MinMaxFlat].map(move |method| { - FutureMoveConfig { - children_eval_method: method, - ..prev_c - } + [ChildrenEvalMethod::MinMax].map(move |method| FutureMoveConfig { + children_eval_method: method, + ..prev_c }) }) .flat_map(move |prev_c| { diff --git a/src/logic/board_value.rs b/src/logic/board_value.rs index a45f92f..b8a03fc 100644 --- a/src/logic/board_value.rs +++ b/src/logic/board_value.rs @@ -33,10 +33,4 @@ impl BoardValueMap { ]; Self(PosMap::from(POSITION_VALUES)) } - - pub const fn flat() -> Self { - Self(PosMap::from( - [[1; Board::SIZE as usize]; Board::SIZE as usize], - )) - } } diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index c327ad9..93d8e9a 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -1,4 +1,4 @@ -use super::r#move::MoveCoord; +use super::r#move::{MoveCoord, MoveValueConfig}; use crate::{ logic::r#move::Move, repr::{Board, Piece, Winner}, @@ -92,8 +92,6 @@ impl std::fmt::Display for FutureMoveConfig { pub enum ChildrenEvalMethod { /// Best so far? MinMax, - - MinMaxFlat, } impl Default for ChildrenEvalMethod { @@ -214,16 +212,7 @@ impl FutureMoves { } fn create_move(&self, coord: MoveCoord, board: Board, color: Piece) -> Move { - Move::new( - coord, - board, - color, - self.agent_color, - !matches!( - self.config.children_eval_method, - ChildrenEvalMethod::MinMaxFlat - ), - ) + Move::new(coord, board, color, self.agent_color, MoveValueConfig {}) } fn generate_children_raw(&self, parent_idx: usize) -> Vec { @@ -299,7 +288,7 @@ impl FutureMoves { let by_depth_vec = self.by_depth(indexes); // reversed so we build up the value of the closest (in time) moves from the future - for (depth, nodes) in by_depth_vec.into_iter().rev() { + for (_depth, nodes) in by_depth_vec.into_iter().rev() { for idx in nodes { let children_values = self.arena[idx] .children @@ -308,7 +297,7 @@ impl FutureMoves { .collect::>(); let children_value = match self.config.children_eval_method { - ChildrenEvalMethod::MinMax | ChildrenEvalMethod::MinMaxFlat => { + ChildrenEvalMethod::MinMax => { if self.arena[idx].color == self.agent_color { // get best (for the adversary) enemy play // this assumes the adversary is playing optimally diff --git a/src/logic/move.rs b/src/logic/move.rs index 7b87f49..08f65cf 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -35,13 +35,15 @@ pub struct Move { pub is_trimmed: bool, } +pub struct MoveValueConfig {} + impl Move { pub fn new( coord: MoveCoord, board: Board, color: Piece, agent_color: Piece, - use_weighted_bvm: bool, + mvc: MoveValueConfig, ) -> Self { let mut m = Move { coord, @@ -53,11 +55,11 @@ impl Move { is_trimmed: false, self_value: 0, }; - m.self_value = m.compute_self_value(agent_color, &board, use_weighted_bvm); + m.self_value = m.compute_self_value(agent_color, &board, mvc); m } - fn compute_self_value(&self, agent_color: Piece, board: &Board, use_weighted_bvm: bool) -> i16 { + fn compute_self_value(&self, agent_color: Piece, board: &Board, _mvc: MoveValueConfig) -> 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. @@ -67,19 +69,10 @@ impl Move { // results in a win for the agent return i16::MAX - 1; } - // else if self.winner == Winner::Tie { - // // idk what a Tie should be valued? - // return 0; - // } // I guess ignore Ties here, don't give them an explicit value, - // because even in the case of ties, we want to have a higher score - match use_weighted_bvm { - true => const { BoardValueMap::weighted() }, - false => const { BoardValueMap::flat() }, - } - .board_value(board, agent_color) + const { BoardValueMap::weighted() }.board_value(board, agent_color) } /// Sort children of the [`Move`] by their self_value in `arena`