logical improvements and cleanup

This commit is contained in:
2025-02-20 20:52:59 -05:00
parent 2011ae001b
commit 3b07a67d2e
3 changed files with 48 additions and 31 deletions

View File

@@ -24,9 +24,11 @@ pub struct Move {
/// Indices of this Move's Children
pub children: Vec<usize>,
/// Value of this move
/// Value of this move (including children)
pub value: i64,
pub self_value: i64,
pub color: Piece,
pub lazy_children: bool,
@@ -37,6 +39,32 @@ lazy_static! {
}
impl Move {
pub fn new(
i: usize,
j: usize,
board: Board,
color: Piece,
lazy_children: bool,
agent_color: Piece,
parent: Option<usize>,
) -> Self {
let mut m = Move {
i,
j,
board,
winner: board.game_winner(),
parent,
children: Vec::new(),
value: 0,
color,
lazy_children,
self_value: 0,
};
m.self_value = m.compute_self_value(agent_color);
m.value = m.self_value;
m
}
pub const fn coords(&self) -> (usize, usize) {
(self.i, self.j)
}