diff --git a/chess_uci/src/lib.rs b/chess_uci/src/lib.rs index 74abb48..d9dfb62 100644 --- a/chess_uci/src/lib.rs +++ b/chess_uci/src/lib.rs @@ -54,10 +54,10 @@ pub enum UciOption { UCIElo { value: Option }, } -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Player { Human { elo: Option }, - Machine { elo: Option }, + Engine { elo: Option }, } pub enum GameOption { WhiteTotalTime { value: Option }, @@ -129,6 +129,10 @@ impl UciEngine { old_value } + pub fn get_player(&self, color: Color) -> Player { + self.player[color.to_index()] + } + /// Launch uci engine initialisation /// /// Retrieve data from uci engine (until uciok command from engine) @@ -149,6 +153,7 @@ impl UciEngine { pub fn new_game(&mut self) { self.initial = Board::default(); self.game = Game::new_with_board(self.initial); + self.push(GuiCommand::Stop); self.push(GuiCommand::UciNewGame); } @@ -326,14 +331,14 @@ impl UciEngine { Err("Invalid move for human player") } } - Player::Machine { .. } => Err("Not a human to play for current color."), + Player::Engine { .. } => Err("Not a human to play for current color."), } } pub fn go(&mut self) -> Result<(), &'static str> { match self.player[self.side_to_move().to_index()] { Player::Human { .. } => Err("Not a machine to play for current color."), - Player::Machine { elo } => { + Player::Engine { elo } => { if self.is_uciok() { if let Some(elo) = elo { self.push(GuiCommand::SetOption { @@ -362,7 +367,7 @@ impl UciEngine { pub fn stop(&mut self) -> Result<(), &'static str> { match self.player[self.side_to_move().to_index()] { Player::Human { .. } => Err("Not a machine to play for current color."), - Player::Machine { .. } => { + Player::Engine { .. } => { self.push(GuiCommand::Stop); Ok(()) } diff --git a/chess_uci_demo/src/main.rs b/chess_uci_demo/src/main.rs index 2376677..d4baf99 100644 --- a/chess_uci_demo/src/main.rs +++ b/chess_uci_demo/src/main.rs @@ -32,7 +32,7 @@ pub fn main() { value: Player::Human { elo: None }, }); uci.game_option(GameOption::BlackPlayer { - value: Player::Machine { elo: Some(1500) }, + value: Player::Engine { elo: Some(1500) }, }); uci.init();