manage (none) best move for mate
This commit is contained in:
parent
da6060cf37
commit
71a166c927
|
@ -71,7 +71,7 @@ pub enum EngineCommand {
|
|||
UciOk,
|
||||
ReadyOk,
|
||||
BestMove {
|
||||
best_move: ChessMove,
|
||||
best_move: Option<ChessMove>,
|
||||
ponder: Option<ChessMove>,
|
||||
},
|
||||
CopyProtection, // unimplemented
|
||||
|
@ -141,16 +141,17 @@ pub fn parse(message: &mut str) -> Result<EngineCommand, &'static str> {
|
|||
Some("readyok") => unimplemented!(),
|
||||
Some("bestmove") => match message_iter.collect::<Vec<&str>>().as_slice() {
|
||||
[] => Err("Empty bestmove command"),
|
||||
["(none)"] => Ok(EngineCommand::BestMove { best_move: None, ponder: None }),
|
||||
[chessmove] => Ok(EngineCommand::BestMove {
|
||||
best_move: ChessMove::from_str(chessmove).expect(&format!("chessmove {:?} is invalid", chessmove)),
|
||||
best_move: Some(
|
||||
ChessMove::from_str(chessmove).expect(&format!("chessmove {:?} is invalid", chessmove))),
|
||||
ponder: None,
|
||||
}),
|
||||
[_, "ponder"] => Err("Empty ponder in bestmove command"),
|
||||
[chessmove, "ponder", chess_ponder] => Ok(EngineCommand::BestMove {
|
||||
best_move: ChessMove::from_str(chessmove).expect("chessmove is invalid"),
|
||||
best_move: Some(ChessMove::from_str(chessmove).expect(&format!("chessmove {:?} is invalid", chessmove))),
|
||||
ponder: Some(
|
||||
ChessMove::from_str(chess_ponder).expect("chessmove ponder is invalid"),
|
||||
),
|
||||
ChessMove::from_str(chess_ponder).expect(&format!("ponder {:?} is invalid", chessmove))),
|
||||
}),
|
||||
_ => Err("Invalid chessmove subcommand"),
|
||||
},
|
||||
|
|
|
@ -63,11 +63,11 @@ pub fn main() {
|
|||
|
||||
uci.push_raw("d\n");
|
||||
|
||||
uci.go().expect("can not make engine move");
|
||||
uci.go();
|
||||
|
||||
loop {
|
||||
match uci.pull() {
|
||||
Some(EngineCommand::BestMove { best_move, .. }) => {
|
||||
Some(EngineCommand::BestMove { best_move: Some(best_move), .. }) => {
|
||||
uci.make_move(&best_move);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue