From 4aa7ee9f2e9d1a2408fa3c955b42bf0e5f42f85c Mon Sep 17 00:00:00 2001 From: Baptiste Fouques Date: Thu, 19 Jan 2023 17:01:34 +0100 Subject: [PATCH] Validate valid move --- chess_uci/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/chess_uci/src/lib.rs b/chess_uci/src/lib.rs index 5f00a53..46b921b 100644 --- a/chess_uci/src/lib.rs +++ b/chess_uci/src/lib.rs @@ -91,9 +91,14 @@ impl UciEngine { /// /// uci.make_move(ChessMove::from_str("e2e4").expect("error converting e2e4")); /// ``` - pub fn make_move(&mut self, chess_move: ChessMove) { - self.game.make_move(chess_move); - self.push(GuiCommand::Position { position: Some(self.initial), moves: self.game.actions().to_vec() }) + pub fn make_move(&mut self, chess_move: ChessMove) -> bool { + if self.game.make_move(chess_move) { + self.push(GuiCommand::Position { position: Some(self.initial), moves: self.game.actions().to_vec() }); + true + } else { + false + } + }