Support debug commands also in XBoard protocol
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 14 Nov 2019 10:47:47 +0000 (11:47 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 14 Nov 2019 10:47:47 +0000 (11:47 +0100)
Commands `d` and `eval` can now also be used in xboard protocol (#47).

src/position.cpp
src/xboard.cpp

index 5dd265d..015d81b 100644 (file)
@@ -2017,7 +2017,7 @@ void Position::flip() {
   string f, token;
   std::stringstream ss(fen());
 
-  for (Rank r = RANK_MAX; r >= RANK_1; --r) // Piece placement
+  for (Rank r = max_rank(); r >= RANK_1; --r) // Piece placement
   {
       std::getline(ss, token, r > RANK_1 ? '/' : ' ');
       f.insert(0, token + (f.empty() ? " " : "/"));
index b8c88f7..a7c0769 100644 (file)
@@ -19,6 +19,7 @@
 #include <iostream>
 #include <string>
 
+#include "evaluate.h"
 #include "search.h"
 #include "thread.h"
 #include "types.h"
@@ -223,6 +224,10 @@ void StateMachine::process_command(Position& pos, std::string token, std::istrin
       is >> perft_limits.perft;
       go(pos, perft_limits, states);
   }
+  else if (token == "d")
+      sync_cout << pos << sync_endl;
+  else if (token == "eval")
+      sync_cout << Eval::trace(pos) << sync_endl;
   // Move strings and unknown commands
   else
   {