Send back a prettyprinted version of the move on hash probe.
[stockfish] / src / client.cpp
index 02980b8d4cb5aff56a4b110db14ca2a2754a450e..a57879050bf0164b61ee14c2b662e3b61eac5818 100644 (file)
 using grpc::Channel;
 using grpc::ClientContext;
 using grpc::Status;
+using namespace hashprobe;
+
+std::string FormatMove(const HashProbeMove &move) {
+  if (move.from_sq().empty()) return "MOVE_NONE";
+  return move.pretty();
+}
 
 int main(int argc, char** argv) {
   std::shared_ptr<Channel> channel(grpc::CreateChannel(
@@ -34,22 +40,38 @@ int main(int argc, char** argv) {
     Status status = stub->Probe(&context, request, &response);
 
     if (status.ok()) {
-      std::cout << response.found() << " "
-                << UCI::square(from_sq(Move(response.move())))
-                << UCI::square(to_sq(Move(response.move()))) << " ";
-      switch (response.bound()) {
-      case HashProbeResponse::BOUND_NONE:
-      case HashProbeResponse::BOUND_EXACT:
-        break;
-      case HashProbeResponse::BOUND_UPPER:
-        std::cout << "<=";
-        break;
-      case HashProbeResponse::BOUND_LOWER:
-        std::cout << ">=";
-        break;
-      } 
-      std::cout << UCI::value(Value(response.value())) << " ";
-      std::cout << response.depth() << std::endl;
+      for (const HashProbeLine &line : response.line()) {
+        std::cout << FormatMove(line.move()) << " ";
+        std::cout << line.found() << " ";
+       for (const HashProbeMove &move : line.pv()) {
+          std::cout << FormatMove(move) << ",";
+        }
+        std::cout << " ";
+        switch (line.bound()) {
+        case HashProbeLine::BOUND_NONE:
+          std::cout << "?";
+          break;
+        case HashProbeLine::BOUND_EXACT:
+          std::cout << "==";
+          break;
+        case HashProbeLine::BOUND_UPPER:
+          std::cout << "<=";
+          break;
+        case HashProbeLine::BOUND_LOWER:
+          std::cout << ">=";
+          break;
+        } 
+       switch (line.value().score_type()) {
+       case HashProbeScore::SCORE_CP:
+         std::cout << " cp " << line.value().score_cp() << " ";
+          break;
+       case HashProbeScore::SCORE_MATE:
+         std::cout << " mate " << line.value().score_mate() << " ";
+          break;
+        }
+        std::cout << line.depth() << std::endl;
+      }
+      std::cout << "END" << std::endl;
     } else {
       std::cout << "ERROR" << std::endl;
     }