5 #include <grpc++/grpc++.h>
7 #include "hashprobe.grpc.pb.h"
12 using grpc::ClientContext;
14 using namespace hashprobe;
16 std::string FormatMove(Move move) {
17 if (move == MOVE_NULL) {
19 } else if (move == MOVE_NONE) {
22 return UCI::square(from_sq(move)) + UCI::square(to_sq(move));
26 int main(int argc, char** argv) {
27 std::shared_ptr<Channel> channel(grpc::CreateChannel(
28 "localhost:50051", grpc::InsecureChannelCredentials()));
29 std::unique_ptr<HashProbe::Stub> stub(HashProbe::NewStub(channel));
33 if (fgets(buf, sizeof(buf), stdin) == nullptr || buf[0] == '\n') {
37 char *ptr = strchr(buf, '\n');
38 if (ptr != nullptr) *ptr = 0;
40 HashProbeRequest request;
43 HashProbeResponse response;
44 ClientContext context;
45 Status status = stub->Probe(&context, request, &response);
48 for (const HashProbeMove &hpmove : response.move()) {
49 std::cout << FormatMove(Move(hpmove.move())) << " ";
50 std::cout << hpmove.found() << " ";
51 std::cout << FormatMove(Move(hpmove.pv_move())) << " ";
52 switch (hpmove.bound()) {
53 case HashProbeMove::BOUND_NONE:
56 case HashProbeMove::BOUND_EXACT:
59 case HashProbeMove::BOUND_UPPER:
62 case HashProbeMove::BOUND_LOWER:
66 std::cout << " " << UCI::value(Value(hpmove.value())) << " ";
67 std::cout << hpmove.depth() << std::endl;
69 std::cout << "END" << std::endl;
71 std::cout << "ERROR" << std::endl;