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

View file

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