From: Steinar H. Gunderson Date: Sat, 19 Mar 2016 21:36:16 +0000 (+0100) Subject: Decode the score into the protobuf. X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=678d7c5c411d6f2f120b7735d292df1d3c66c601 Decode the score into the protobuf. --- diff --git a/src/client.cpp b/src/client.cpp index 9f203575..6049495a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -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; diff --git a/src/hashprobe.proto b/src/hashprobe.proto index 42f6b2b4..dfd16fdc 100644 --- a/src/hashprobe.proto +++ b/src/hashprobe.proto @@ -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) {} diff --git a/src/main.cpp b/src/main.cpp index d851bda0..a5ed56ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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()