From 2abde4eac86bee36edfbcf6eaca51923fe2e0267 Mon Sep 17 00:00:00 2001 From: borg323 Date: Mon, 16 Dec 2024 01:16:29 +0200 Subject: [PATCH 1/2] print some uci info output in value only mode --- src/engine.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/engine.cc b/src/engine.cc index e4157657c6..f66a9e7b04 100644 --- a/src/engine.cc +++ b/src/engine.cc @@ -291,6 +291,7 @@ void ValueOnlyGo(NodeTree* tree, Network* network, const OptionsDict& options, } std::vector comp_q; + std::vector comp_d; int batch_size = options.Get(SearchParams::kMiniBatchSizeId); if (batch_size == 0) batch_size = network->GetMiniBatchSize(); @@ -302,37 +303,50 @@ void ValueOnlyGo(NodeTree* tree, Network* network, const OptionsDict& options, } comp->ComputeBlocking(); - for (int j = 0; j < batch_size; j++) comp_q.push_back(comp->GetQVal(j)); + for (int j = 0; j < batch_size; j++) { + comp_q.push_back(comp->GetQVal(j)); + comp_d.push_back(comp->GetDVal(j)); + } } Move best; int comp_idx = 0; float max_q = std::numeric_limits::lowest(); + ThinkingInfo::WDL wdl; for (auto edge : tree->GetCurrentHead()->Edges()) { history.Append(edge.GetMove()); auto result = history.ComputeGameResult(); float q = -1; + float d = 0; if (result == GameResult::UNDECIDED) { // NN eval is for side to move perspective - so if its good, its bad for // us. q = -comp_q[comp_idx]; + d = comp_d[comp_idx]; comp_idx++; } else if (result == GameResult::DRAW) { q = 0; + d = 1; } else { // A legal move to a non-drawn terminal without tablebases must be a // win. q = 1; + d = 0; } if (q >= max_q) { max_q = q; best = edge.GetMove(tree->GetPositionHistory().IsBlackToMove()); + wdl = {500*(1+q-d),1000*d,500*(1-q-d)}; } history.Pop(); } std::vector infos; ThinkingInfo thinking; thinking.depth = 1; + thinking.seldepth = 1; + thinking.score = 90 * tan(1.5637541897 * max_q); + thinking.wdl = wdl; + thinking.nodes = tree->GetCurrentHead()->Edges().size(); infos.push_back(thinking); responder->OutputThinkingInfo(&infos); BestMoveInfo info(best); From 70b17cd301fff925a766230ecd5573e6f1f01234 Mon Sep 17 00:00:00 2001 From: borg323 Date: Mon, 16 Dec 2024 01:25:24 +0200 Subject: [PATCH 2/2] fix and cleanup --- src/engine.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine.cc b/src/engine.cc index f66a9e7b04..b91f83aae9 100644 --- a/src/engine.cc +++ b/src/engine.cc @@ -336,7 +336,9 @@ void ValueOnlyGo(NodeTree* tree, Network* network, const OptionsDict& options, if (q >= max_q) { max_q = q; best = edge.GetMove(tree->GetPositionHistory().IsBlackToMove()); - wdl = {500*(1+q-d),1000*d,500*(1-q-d)}; + wdl = {static_cast(std::round(500 * (1 + q - d))), + static_cast(std::round(1000 * d)), + static_cast(std::round(500 * (1 - q - d)))}; } history.Pop(); } @@ -346,7 +348,7 @@ void ValueOnlyGo(NodeTree* tree, Network* network, const OptionsDict& options, thinking.seldepth = 1; thinking.score = 90 * tan(1.5637541897 * max_q); thinking.wdl = wdl; - thinking.nodes = tree->GetCurrentHead()->Edges().size(); + thinking.nodes = tree->GetCurrentHead()->GetNumEdges(); infos.push_back(thinking); responder->OutputThinkingInfo(&infos); BestMoveInfo info(best);