othello/src/complexagent.rs

50 lines
1.1 KiB
Rust

use crate::{
agent::Agent,
logic::{FutureMoveConfig, FutureMoves},
repr::{Board, Piece},
};
pub struct ComplexAgent {
color: Piece,
future_moves: FutureMoves,
}
#[allow(dead_code)]
impl ComplexAgent {
pub const fn new(color: Piece) -> Self {
const CONFIG: FutureMoveConfig = FutureMoveConfig {
max_depth: 10,
min_arena_depth_sub: 3,
top_k_children: 2,
up_to_minus: 4,
max_arena_size: 10_000_000,
};
Self {
color,
future_moves: FutureMoves::new(color, CONFIG),
}
}
}
impl Agent for ComplexAgent {
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
self.future_moves.update_from_board(board);
println!("# of moves stored: {}", self.future_moves.arena_len());
self.future_moves.best_move().inspect(|&(i, j)| {
if !self.future_moves.update_root_coord(i, j) {
panic!("update_root_coord failed");
}
})
}
fn name(&self) -> &'static str {
"Complex Agent"
}
fn color(&self) -> Piece {
self.color
}
}