Move: add bvm option
This commit is contained in:
parent
f51c940b3f
commit
c46b8ef8b8
@ -37,8 +37,6 @@ pub struct Move {
|
|||||||
pub is_trimmed: bool,
|
pub is_trimmed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const BVM: BoardValueMap = BoardValueMap::weighted();
|
|
||||||
|
|
||||||
impl Move {
|
impl Move {
|
||||||
pub fn new(coord: Option<CoordPair>, board: Board, color: Piece, agent_color: Piece) -> Self {
|
pub fn new(coord: Option<CoordPair>, board: Board, color: Piece, agent_color: Piece) -> Self {
|
||||||
let mut m = Move {
|
let mut m = Move {
|
||||||
@ -52,11 +50,11 @@ impl Move {
|
|||||||
self_value: 0,
|
self_value: 0,
|
||||||
tried_children: false,
|
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
|
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 self.winner == Winner::Player(!agent_color) {
|
||||||
// if this board results in the opponent winning, MAJORLY negatively weigh this move
|
// 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.
|
// 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,
|
// 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
|
// 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`
|
/// Sort children of the [`Move`] by their self_value in `arena`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user