From 54cfd43911b61e7aabe7dcdc5f984f496e672c5d Mon Sep 17 00:00:00 2001 From: dece Date: Wed, 24 Jun 2020 22:17:36 +0200 Subject: [PATCH] engine: use "vatunode" as debug log command --- src/engine.rs | 13 ++++++++----- src/uci.rs | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index 8cb3738..2419118 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -62,8 +62,8 @@ pub enum Cmd { WorkerInfo(Vec), /// Send best move found by analysis worker. WorkerBestMove(Option), - /// 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), } diff --git a/src/uci.rs b/src/uci.rs index eaa5079..f7f2cff 100644 --- a/src/uci.rs +++ b/src/uci.rs @@ -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()), } }