othello/src/complexagent.rs

39 lines
798 B
Rust

use crate::{
agent::Agent,
logic::{FutureMoveConfig, FutureMoves},
repr::{Board, CoordPair, Piece},
};
pub struct ComplexAgent {
color: Piece,
future_moves: FutureMoves,
}
#[allow(dead_code)]
impl ComplexAgent {
pub const fn new(color: Piece, config: FutureMoveConfig) -> Self {
Self {
color,
future_moves: FutureMoves::new(color, config),
}
}
}
impl Agent for ComplexAgent {
fn next_move(&mut self, board: &Board) -> Option<CoordPair> {
self.future_moves.update_from_board(board);
self.future_moves
.best_move()
.expect("FutureMoves has no move?")
}
fn name(&self) -> &'static str {
"Complex Agent"
}
fn color(&self) -> Piece {
self.color
}
}