]> git.sesse.net Git - stockfish/blobdiff - src/client.cpp
Remove the non-pretty moves from the protobuf, as it takes up a little CPU time for...
[stockfish] / src / client.cpp
index 02980b8d4cb5aff56a4b110db14ca2a2754a450e..a59b961ad9736ac73ca68d85f0d6c0347906499e 100644 (file)
 using grpc::Channel;
 using grpc::ClientContext;
 using grpc::Status;
+using namespace hashprobe;
+
+std::string FormatMove(const HashProbeMove &move) {
+  if (move.pretty().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;
     }