Move: add bvm option

This commit is contained in:
Simon Gardling 2025-03-20 01:19:07 -04:00
parent f51c940b3f
commit c46b8ef8b8
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -37,8 +37,6 @@ pub struct Move {
pub is_trimmed: bool,
}
const BVM: BoardValueMap = BoardValueMap::weighted();
impl Move {
pub fn new(coord: Option<CoordPair>, 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`