From c46b8ef8b816cdfd4fc442c1d5805a871e6feb72 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 20 Mar 2025 01:19:07 -0400 Subject: [PATCH] Move: add bvm option --- src/logic/move.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/logic/move.rs b/src/logic/move.rs index 56645ab..453aefb 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -37,8 +37,6 @@ pub struct Move { pub is_trimmed: bool, } -const BVM: BoardValueMap = BoardValueMap::weighted(); - impl Move { pub fn new(coord: Option, board: Board, color: Piece, agent_color: Piece) -> Self { let mut m = Move { @@ -52,11 +50,11 @@ impl Move { self_value: 0, tried_children: false, }; - m.self_value = m.compute_self_value(agent_color, &board); + m.self_value = m.compute_self_value(agent_color, &board, true); m } - fn compute_self_value(&self, agent_color: Piece, board: &Board) -> i16 { + fn compute_self_value(&self, agent_color: Piece, board: &Board, use_weighted_bvm: bool) -> 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. @@ -73,7 +71,12 @@ impl Move { // 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 - BVM.board_value(board, agent_color) + + match use_weighted_bvm { + true => const { BoardValueMap::weighted() }, + false => const { BoardValueMap::flat() }, + } + .board_value(board, agent_color) } /// Sort children of the [`Move`] by their self_value in `arena`