engine: use "vatunode" as debug log command

This commit is contained in:
dece 2020-06-24 22:17:36 +02:00
parent 7ff52bc2b5
commit 54cfd43911
2 changed files with 12 additions and 9 deletions

View file

@ -62,8 +62,8 @@ pub enum Cmd {
WorkerInfo(Vec<analysis::AnalysisInfo>),
/// Send best move found by analysis worker.
WorkerBestMove(Option<Move>),
/// Draw board in logs.
DrawBoard,
/// Log current node.
LogNode,
// Commands that can be sent by the engine.
@ -127,11 +127,14 @@ impl Engine {
Cmd::WorkerInfo(infos) => self.reply(Cmd::Info(infos.to_vec())),
Cmd::WorkerBestMove(m) => self.reply(Cmd::BestMove(m.clone())),
// Other commands.
Cmd::DrawBoard => {
Cmd::LogNode => {
let mut s = vec!();
self.node.board.draw_to(&mut s);
let s = format!("{}", String::from_utf8_lossy(&s));
self.reply(Cmd::Log(s));
self.reply(Cmd::Log(format!(
"Current node:\n{}{}",
String::from_utf8_lossy(&s),
self.node.game_state
)));
}
_ => eprintln!("Not an engine input command: {:?}", cmd),
}

View file

@ -59,7 +59,7 @@ pub enum UciCmd {
Quit,
// Unofficial commands mostly for debugging.
VatuDraw,
VatuNode,
Unknown(String),
}
@ -202,8 +202,8 @@ impl Uci {
self.send_engine_command(engine::Cmd::Stop);
},
UciCmd::Quit => return false,
UciCmd::VatuDraw => {
self.send_engine_command(engine::Cmd::DrawBoard);
UciCmd::VatuNode => {
self.send_engine_command(engine::Cmd::LogNode);
}
UciCmd::Unknown(c) => { self.log(format!("Unknown command: {}", c)); }
}
@ -312,7 +312,7 @@ fn parse_command(s: &str) -> UciCmd {
"position" => parse_position_command(&fields[1..]),
"go" => parse_go_command(&fields[1..]),
"quit" => UciCmd::Quit,
"vatudraw" => UciCmd::VatuDraw,
"vatunode" => UciCmd::VatuNode,
c => UciCmd::Unknown(c.to_string()),
}
}