From 67115d5879ec6842e974ee6965a7f7afc2be0e4c Mon Sep 17 00:00:00 2001 From: Dieter Dobbelaere <38748663+ddobbelaere@users.noreply.github.com> Date: Sun, 17 Mar 2019 21:39:43 +0100 Subject: [PATCH 1/2] Fix compiler comparison warnings. (#790) --- src/mcts/search.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index ae4169e6d9..b49c7c2227 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -239,8 +239,8 @@ std::vector Search::GetVerboseStats(Node* node, oss << "(Q: " << std::setw(8) << std::setprecision(5) << edge.GetQ(fpu) << ") "; - oss << "(D: " << std::setw(6) << std::setprecision(3) - << edge.GetD() << ") "; + oss << "(D: " << std::setw(6) << std::setprecision(3) << edge.GetD() + << ") "; oss << "(U: " << std::setw(6) << std::setprecision(5) << edge.GetU(U_coeff) << ") "; @@ -327,12 +327,12 @@ void Search::UpdateKLDGain() { if (prev_dist_.size() != 0) { double sum1 = 0.0; double sum2 = 0.0; - for (int i = 0; i < new_visits.size(); i++) { + for (decltype(new_visits)::size_type i = 0; i < new_visits.size(); i++) { sum1 += prev_dist_[i]; sum2 += new_visits[i]; } double kldgain = 0.0; - for (int i = 0; i < new_visits.size(); i++) { + for (decltype(new_visits)::size_type i = 0; i < new_visits.size(); i++) { double o_p = prev_dist_[i] / sum1; double n_p = new_visits[i] / sum2; if (prev_dist_[i] != 0) { @@ -422,8 +422,8 @@ void Search::UpdateRemainingMoves() { if (time_since_start > kSmartPruningToleranceMs) { const auto nps = 1000LL * (total_playouts_ + kSmartPruningToleranceNodes) / - time_since_start + - 1; + time_since_start + + 1; const int64_t remaining_time = GetTimeToDeadline(); // Put early_exit scaler here so calculation doesn't have to be done on // every node. @@ -439,8 +439,8 @@ void Search::UpdateRemainingMoves() { // Add kMiniBatchSize, as it's possible to exceed visits limit by that // number. const auto remaining_visits = limits_.visits - total_playouts_ - - initial_visits_ + - params_.GetMiniBatchSize() - 1; + initial_visits_ + params_.GetMiniBatchSize() - + 1; if (remaining_visits < remaining_playouts_) remaining_playouts_ = remaining_visits; @@ -498,10 +498,11 @@ bool Search::PopulateRootMoveLimit(MoveList* root_moves) const { (board.ours() | board.theirs()).count() > syzygy_tb_->max_cardinality()) { return false; } - return syzygy_tb_->root_probe(played_history_.Last(), - params_.GetSyzygyFastPlay() || - played_history_.DidRepeatSinceLastZeroingMove(), - root_moves) || + return syzygy_tb_->root_probe( + played_history_.Last(), + params_.GetSyzygyFastPlay() || + played_history_.DidRepeatSinceLastZeroingMove(), + root_moves) || syzygy_tb_->root_probe_wdl(played_history_.Last(), root_moves); } @@ -558,7 +559,7 @@ std::vector Search::GetBestChildrenNoTemperature(Node* parent, } const auto middle = (static_cast(edges.size()) > count) ? edges.begin() + count - : edges.end(); + : edges.end(); std::partial_sort(edges.begin(), middle, edges.end(), std::greater()); std::vector res; From daf933e52aeb716c7d0e6daaac29c96366717a1b Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Wed, 20 Mar 2019 03:34:09 -0400 Subject: [PATCH 2/2] Update TempVisitOffset help text and allowed values. (#771) --- src/mcts/params.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mcts/params.cc b/src/mcts/params.cc index 416aca51b7..15f7133ba0 100644 --- a/src/mcts/params.cc +++ b/src/mcts/params.cc @@ -84,9 +84,9 @@ const OptionId SearchParams::kTemperatureWinpctCutoffId{ "probability less than X than the best move) are not considered at all."}; const OptionId SearchParams::kTemperatureVisitOffsetId{ "temp-visit-offset", "TempVisitOffset", - "Reduces visits by this value when picking a move with a temperature. When " - "the offset is less than number of visits for a particular move, that move " - "is not picked at all."}; + "Adjusts visits by this value when picking a move with a temperature. If a " + "negative offset reduces visits for a particular move below zero, that " + "move is not picked. If no moves can be picked, no temperature is used."}; const OptionId SearchParams::kNoiseId{ "noise", "DirichletNoise", "Add Dirichlet noise to root node prior probabilities. This allows the " @@ -192,7 +192,7 @@ void SearchParams::Populate(OptionsParser* options) { options->Add(kTemperatureCutoffMoveId, 0, 1000) = 0; options->Add(kTemperatureEndgameId, 0.0f, 100.0f) = 0.0f; options->Add(kTemperatureWinpctCutoffId, 0.0f, 100.0f) = 100.0f; - options->Add(kTemperatureVisitOffsetId, -0.99999f, 1000.0f) = + options->Add(kTemperatureVisitOffsetId, -1000.0f, 1000.0f) = 0.0f; options->Add(kNoiseId) = false; options->Add(kVerboseStatsId) = false;