X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fclient.cpp;h=b3ec68f85cf6226042224bc27f7a8696a14c032f;hp=05fe59723c362a14c875aeb067fbdd1eebb50e4b;hb=90cbc12e9845f1a523ca44bbd2d86a23cc7df883;hpb=19b710c424cb4d07a304159baf0283d06ec2a313 diff --git a/src/client.cpp b/src/client.cpp index 05fe5972..b3ec68f8 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -5,6 +5,8 @@ #include #include "hashprobe.grpc.pb.h" +#include "types.h" +#include "uci.h" using grpc::Channel; using grpc::ClientContext; @@ -15,18 +17,51 @@ int main(int argc, char** argv) { "localhost:50051", grpc::InsecureChannelCredentials())); std::unique_ptr 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]); + for ( ;; ) { + char buf[256]; + if (fgets(buf, sizeof(buf), stdin) == nullptr || buf[0] == '\n') { + exit(0); + } - HashProbeResponse response; - ClientContext context; - Status status = stub->Probe(&context, request, &response); + char *ptr = strchr(buf, '\n'); + if (ptr != nullptr) *ptr = 0; - if (status.ok()) { - std::cout << response.DebugString(); - } else { - std::cout << "RPC failed"; + HashProbeRequest request; + request.set_fen(buf); + + HashProbeResponse response; + ClientContext context; + Status status = stub->Probe(&context, request, &response); + + if (status.ok()) { + std::cout << response.found() << " "; + if (Move(response.move()) == MOVE_NULL) { + std::cout << "Null-move "; + } else if (Move(response.move()) == MOVE_NONE) { + std::cout << "MOVE_NONE "; + } else { + std::cout << UCI::square(from_sq(Move(response.move()))) + << UCI::square(to_sq(Move(response.move()))) << " "; + } + switch (response.bound()) { + case HashProbeResponse::BOUND_NONE: + std::cout << "?"; + break; + case HashProbeResponse::BOUND_EXACT: + std::cout << "=="; + 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;