5 #include <grpc++/grpc++.h>
7 #include "hashprobe.grpc.pb.h"
12 using grpc::ClientContext;
15 std::string FormatMove(Move move) {
16 if (move == MOVE_NULL) {
18 } else if (move == MOVE_NONE) {
21 return UCI::square(from_sq(move)) + UCI::square(to_sq(move));
25 int main(int argc, char** argv) {
26 std::shared_ptr<Channel> channel(grpc::CreateChannel(
27 "localhost:50051", grpc::InsecureChannelCredentials()));
28 std::unique_ptr<HashProbe::Stub> stub(HashProbe::NewStub(channel));
32 if (fgets(buf, sizeof(buf), stdin) == nullptr || buf[0] == '\n') {
36 char *ptr = strchr(buf, '\n');
37 if (ptr != nullptr) *ptr = 0;
39 HashProbeRequest request;
42 HashProbeResponse response;
43 ClientContext context;
44 Status status = stub->Probe(&context, request, &response);
47 for (const HashProbeMove &hpmove : response.move()) {
48 std::cout << FormatMove(Move(hpmove.move())) << " ";
49 std::cout << hpmove.found() << " ";
50 std::cout << FormatMove(Move(hpmove.pv_move())) << " ";
51 switch (hpmove.bound()) {
52 case HashProbeMove::BOUND_NONE:
55 case HashProbeMove::BOUND_EXACT:
58 case HashProbeMove::BOUND_UPPER:
61 case HashProbeMove::BOUND_LOWER:
65 std::cout << " " << UCI::value(Value(hpmove.value())) << " ";
66 std::cout << hpmove.depth() << std::endl;
68 std::cout << "END" << std::endl;
70 std::cout << "ERROR" << std::endl;