use std::time::Duration; use crate::{board::Board, player::Player, moves::Move}; use self::ttable::{TranspositionTable, TTABLE_SIZE}; mod ttable; mod evaluation; mod search; /// Grossmeister is a powerful entity that plays the game of Chess. /// This structure represents a player, it stores his knowledge /// and experience about the game. pub struct Grossmeister { /// GM's internal board representation /// This is usually a copy of a real board board: Board, /// Transposition table is a cache of all positions that Grossmeister /// has seen and evaluated. /// It's indexex by Zobrist hash of a position mod size transposition_table: TranspositionTable, } impl Default for Grossmeister { fn default() -> Self { Self::new(Board::default()) } } impl Grossmeister { pub fn new(board: Board) -> Self { Self { board, transposition_table: vec![None; TTABLE_SIZE as usize], } } } impl Player for Grossmeister { fn analyze(&mut self, board: Board, duration: Duration) -> (f32, Vec) { self.board = board; // Copy the board into GM's head self.iterative_deepening(8, duration, true) } }