Validate valid move

This commit is contained in:
Baptiste Fouques 2023-01-19 17:01:34 +01:00
parent 58514844a8
commit 4aa7ee9f2e
1 changed files with 8 additions and 3 deletions

View File

@ -91,9 +91,14 @@ impl<Fi: Read, Fo: Write> UciEngine<Fi, Fo> {
///
/// 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
}
}