]> git.sesse.net Git - stockfish/commitdiff
Make the client prober output something a bit more easily parseable, and run in a...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 17 Mar 2016 01:12:13 +0000 (02:12 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 26 Dec 2018 09:43:37 +0000 (10:43 +0100)
src/Makefile
src/client.cpp

index 2e8a49287d45047f7e52cf4ba8e2aa3e1c07abce..cd79223a7f0b32e8d5f16aa7dc5292043f673eed 100644 (file)
@@ -40,7 +40,7 @@ OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
        material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o \
        search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o \
        hashprobe.grpc.pb.o hashprobe.pb.o
-CLIOBJS = client.o hashprobe.grpc.pb.o hashprobe.pb.o
+CLIOBJS = client.o hashprobe.grpc.pb.o hashprobe.pb.o uci.o
 
 ### Establish the operating system name
 KERNEL = $(shell uname -s)
index 05fe59723c362a14c875aeb067fbdd1eebb50e4b..02980b8d4cb5aff56a4b110db14ca2a2754a450e 100644 (file)
@@ -5,6 +5,8 @@
 #include <grpc++/grpc++.h>
 
 #include "hashprobe.grpc.pb.h"
+#include "types.h"
+#include "uci.h"
 
 using grpc::Channel;
 using grpc::ClientContext;
@@ -15,18 +17,42 @@ int main(int argc, char** argv) {
       "localhost:50051", grpc::InsecureChannelCredentials()));
   std::unique_ptr<HashProbe::Stub> stub(HashProbe::NewStub(channel));
 
-  HashProbeRequest request;
-//  request.set_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
-  request.set_fen(argv[1]);
-
-  HashProbeResponse response;
-  ClientContext context;
-  Status status = stub->Probe(&context, request, &response);
-
-  if (status.ok()) {
-    std::cout << response.DebugString();
-  } else {
-    std::cout << "RPC failed";
+  for ( ;; ) {
+    char buf[256];
+    if (fgets(buf, sizeof(buf), stdin) == nullptr || buf[0] == '\n') {
+      exit(0);
+    }
+
+    char *ptr = strchr(buf, '\n');
+    if (ptr != nullptr) *ptr = 0;
+
+    HashProbeRequest request;
+    request.set_fen(buf);
+
+    HashProbeResponse response;
+    ClientContext context;
+    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;
+    } else {
+      std::cout << "ERROR" << std::endl;
+    }
   }
 
   return 0;