allow move arena to properly handle skipping a move

This commit is contained in:
2025-02-26 22:58:47 -05:00
parent 4a82c01d64
commit d3cac6ae91
2 changed files with 43 additions and 56 deletions

View File

@@ -4,11 +4,8 @@ use lazy_static::lazy_static;
#[derive(Clone, Debug)]
pub struct Move {
/// `i` position of move
pub i: usize,
/// `j` position of move
pub j: usize,
/// Coordinates (i, j) of the move (if it exists)
pub coord: Option<(usize, usize)>,
/// [`Board`] state after move is made
pub board: Board,
@@ -43,10 +40,14 @@ lazy_static! {
}
impl Move {
pub fn new(i: usize, j: usize, board: Board, color: Piece, agent_color: Piece) -> Self {
pub fn new(
coord: Option<(usize, usize)>,
board: Board,
color: Piece,
agent_color: Piece,
) -> Self {
let mut m = Move {
i,
j,
coord,
board,
winner: board.game_winner(),
parent: None,
@@ -61,10 +62,6 @@ impl Move {
m
}
pub const fn coords(&self) -> (usize, usize) {
(self.i, self.j)
}
fn compute_self_value(&self, agent_color: Piece) -> i64 {
if self.winner == Winner::Player(!agent_color) {
// if this board results in the opponent winning, MAJORLY negatively weigh this move