Skip to content

Commit

Permalink
Merge branch 'master' into cp-master
Browse files Browse the repository at this point in the history
  • Loading branch information
MelleKoning committed Mar 21, 2019
2 parents edb55d3 + daf933e commit de0414b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/mcts/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -200,7 +200,7 @@ void SearchParams::Populate(OptionsParser* options) {
options->Add<IntOption>(kTemperatureCutoffMoveId, 0, 1000) = 0;
options->Add<FloatOption>(kTemperatureEndgameId, 0.0f, 100.0f) = 0.0f;
options->Add<FloatOption>(kTemperatureWinpctCutoffId, 0.0f, 100.0f) = 100.0f;
options->Add<FloatOption>(kTemperatureVisitOffsetId, -0.99999f, 1000.0f) =
options->Add<FloatOption>(kTemperatureVisitOffsetId, -1000.0f, 1000.0f) =
0.0f;
options->Add<BoolOption>(kNoiseId) = false;
options->Add<BoolOption>(kVerboseStatsId) = false;
Expand Down
29 changes: 13 additions & 16 deletions src/mcts/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,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) {
Expand Down Expand Up @@ -437,8 +437,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.
Expand All @@ -454,8 +454,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;
Expand Down Expand Up @@ -516,15 +516,12 @@ int Search::PopulateRootMoveLimit(MoveList* root_moves) const {
(board.ours() | board.theirs()).count() > syzygy_tb_->max_cardinality()) {
return 0;
}

int best_rank = syzygy_tb_->root_probe(
played_history_.Last(),
params_.GetSyzygyFastPlay() ||
played_history_.DidRepeatSinceLastZeroingMove(),
root_moves);
if (!best_rank)
best_rank = syzygy_tb_->root_probe_wdl(played_history_.Last(), root_moves);
return best_rank;
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);
}

// Computes the best move, maybe with temperature (according to the settings).
Expand Down Expand Up @@ -606,7 +603,7 @@ std::vector<EdgeAndNode> Search::GetBestChildrenNoTemperature(Node* parent,
// Final sort pass.
const auto middle = (static_cast<int>(edges.size()) > count)
? edges.begin() + count
: edges.end();
: edges.end();
std::partial_sort(edges.begin(), middle, edges.end(), std::greater<El>());

std::vector<EdgeAndNode> res;
Expand Down

0 comments on commit de0414b

Please sign in to comment.