44 lines
943 B
Rust
44 lines
943 B
Rust
use crate::{
|
|
agent::Agent,
|
|
logic::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 MAX_DEPTH: usize = 12;
|
|
Self {
|
|
color,
|
|
future_moves: FutureMoves::new(color, MAX_DEPTH, 4),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Agent for ComplexAgent {
|
|
fn next_move(&mut self, board: &Board) -> Option<(usize, usize)> {
|
|
self.future_moves.update(board);
|
|
|
|
println!("# of moves stored: {}", self.future_moves.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
|
|
}
|
|
}
|