diff --git a/src/game_inner.rs b/src/game_inner.rs index ac688bb..627aa23 100644 --- a/src/game_inner.rs +++ b/src/game_inner.rs @@ -1,6 +1,7 @@ use crate::{ agent::{Agent, AgentMove}, - repr::{Board, CoordPair, Piece, Winner}, + logic::MoveCoord, + repr::{Board, Piece, Winner}, }; impl std::fmt::Display for GameInner { @@ -30,7 +31,7 @@ pub struct GameInner { players: [Box; 2], board: Board, do_print: bool, - move_log: Vec<(Option, Piece)>, + move_log: Vec<(MoveCoord, Piece)>, first_board: Board, } diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index 1590ede..fbb5d8d 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -1,6 +1,6 @@ use crate::{ logic::r#move::Move, - repr::{Board, CoordPair, Piece, Winner}, + repr::{Board, Piece, Winner}, }; use allocative::Allocative; use indicatif::{ParallelProgressIterator, ProgressStyle}; @@ -15,6 +15,8 @@ use std::{ }, }; +use super::r#move::MoveCoord; + #[derive(Allocative)] pub struct FutureMoves { /// Arena containing all [`Move`] @@ -354,7 +356,7 @@ impl FutureMoves { } } - fn move_history(&self, idx: usize) -> Option, Piece)>> { + fn move_history(&self, idx: usize) -> Option> { if let Some(root) = self.current_root { let mut hist = Vec::new(); @@ -395,7 +397,7 @@ impl FutureMoves { } /// Return the best move which is a child of `self.current_root` - pub fn best_move(&self) -> Option> { + pub fn best_move(&self) -> Option { self.current_root .and_then(|x| { self.arena[x] diff --git a/src/logic/mod.rs b/src/logic/mod.rs index 84e956d..d84d58b 100644 --- a/src/logic/mod.rs +++ b/src/logic/mod.rs @@ -2,3 +2,4 @@ mod board_value; mod future_moves; mod r#move; pub use future_moves::{ChildrenEvalMethod, FutureMoveConfig, FutureMoves}; +pub use r#move::MoveCoord; diff --git a/src/logic/move.rs b/src/logic/move.rs index 0268c56..5a23f7d 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -2,10 +2,12 @@ use super::board_value::BoardValueMap; use crate::repr::{Board, CoordPair, Piece, Winner}; use allocative::Allocative; +pub type MoveCoord = Option; + #[derive(Clone, Debug, Allocative)] pub struct Move { /// Coordinates (i, j) of the move (if it exists) - pub coord: Option, + pub coord: MoveCoord, /// Current winner of the match pub winner: Winner, @@ -34,7 +36,7 @@ pub struct Move { } impl Move { - pub fn new(coord: Option, board: Board, color: Piece, agent_color: Piece) -> Self { + pub fn new(coord: MoveCoord, board: Board, color: Piece, agent_color: Piece) -> Self { let mut m = Move { coord, winner: board.game_winner(),