]> git.sesse.net Git - stockfish/commitdiff
Decode the score into the protobuf.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 19 Mar 2016 21:36:16 +0000 (22:36 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 26 Dec 2018 09:43:37 +0000 (10:43 +0100)
src/client.cpp
src/hashprobe.proto
src/main.cpp

index 9f203575a1c735b941506b9e7924e00a22627b41..6049495a4a0d430a9660fdaadf9580f334c7fa42 100644 (file)
@@ -61,7 +61,14 @@ int main(int argc, char** argv) {
           std::cout << ">=";
           break;
         } 
-        std::cout << " " << UCI::value(Value(line.value())) << " ";
+       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;
index 42f6b2b466abc4e27ac7bea0dde25c77a999d650..dfd16fdcd3dcfbd4bcdc75799449d6cce69c48af 100644 (file)
@@ -13,8 +13,8 @@ message HashProbeLine {
        bool found = 2;
 
        repeated HashProbeMove pv = 3;
-       int32 value = 4;  // Dynamic eval (may be inexact, see the "bound" field)
-       int32 eval = 5;  // Static eval
+       HashProbeScore value = 4;  // Dynamic eval (may be inexact, see the "bound" field)
+       HashProbeScore eval = 5;  // Static eval
        int32 depth = 6;
 
        enum ValueBound {
@@ -31,6 +31,15 @@ message HashProbeMove {
        string to_sq = 2;
        string promotion = 3;  // Q, R, etc.
 }
+message HashProbeScore {
+       enum ScoreType {
+               SCORE_CP = 0;
+               SCORE_MATE = 1;
+       }
+       ScoreType score_type = 1;
+       int32 score_cp = 2;
+       int32 score_mate = 3;
+}
 
 service HashProbe {
        rpc Probe(HashProbeRequest) returns (HashProbeResponse) {}
index d851bda055c2e63468165f0bfb3fa91a05d80c6e..a5ed56ec3b77cba9d195e24ed705c0c18793f5b2 100644 (file)
@@ -107,8 +107,8 @@ public:
                        }
 
                        response->set_depth(entry->depth());
-                       response->set_eval(eval);
-                       response->set_value(value);
+                       FillValue(eval, response->mutable_eval());
+                       FillValue(value, response->mutable_value());
                        response->set_bound(HashProbeLine::ValueBound(bound));
 
                        // Follow the PV until we hit an illegal move.
@@ -131,6 +131,16 @@ public:
                        }
                }
        }
+
+       void FillValue(Value value, HashProbeScore* score) {
+               if (abs(value) < VALUE_MATE - MAX_PLY) {
+                       score->set_score_type(HashProbeScore::SCORE_CP);
+                       score->set_score_cp(value * 100 / PawnValueEg);
+               } else {
+                       score->set_score_type(HashProbeScore::SCORE_MATE);
+                       score->set_score_mate((value > 0 ? VALUE_MATE - value + 1 : -VALUE_MATE - value) / 2);
+               }
+       }
 };
        
 void rpc_thread()