typing improvements
This commit is contained in:
parent
85e3a11897
commit
625b02c13a
@ -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<dyn Agent>; 2],
|
||||
board: Board,
|
||||
do_print: bool,
|
||||
move_log: Vec<(Option<CoordPair>, Piece)>,
|
||||
move_log: Vec<(MoveCoord, Piece)>,
|
||||
first_board: Board,
|
||||
}
|
||||
|
||||
|
||||
@ -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<Vec<(Option<CoordPair>, Piece)>> {
|
||||
fn move_history(&self, idx: usize) -> Option<Vec<(MoveCoord, Piece)>> {
|
||||
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<Option<CoordPair>> {
|
||||
pub fn best_move(&self) -> Option<MoveCoord> {
|
||||
self.current_root
|
||||
.and_then(|x| {
|
||||
self.arena[x]
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -2,10 +2,12 @@ use super::board_value::BoardValueMap;
|
||||
use crate::repr::{Board, CoordPair, Piece, Winner};
|
||||
use allocative::Allocative;
|
||||
|
||||
pub type MoveCoord = Option<CoordPair>;
|
||||
|
||||
#[derive(Clone, Debug, Allocative)]
|
||||
pub struct Move {
|
||||
/// Coordinates (i, j) of the move (if it exists)
|
||||
pub coord: Option<CoordPair>,
|
||||
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<CoordPair>, 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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user