Skip to content

Commit d7c5d5e

Browse files
TilpsAlexisOlson
authored andcommitted
Fix bug where pv might not update for best move change. (LeelaChessZero#1286)
* Fix bug where pv might not update. * Fix...
1 parent 8573f15 commit d7c5d5e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/mcts/search.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,8 @@ void SearchWorker::DoBackupUpdateSingleNode(
15261526
// Nothing left to do without ancestors to update.
15271527
if (!p) break;
15281528

1529+
bool old_update_parent_bounds = update_parent_bounds;
1530+
15291531
// Try setting parent bounds except the root or those already terminal.
15301532
update_parent_bounds = update_parent_bounds && p != search_->root_node_ &&
15311533
!p->IsTerminal() && MaybeSetBounds(p, m);
@@ -1537,8 +1539,16 @@ void SearchWorker::DoBackupUpdateSingleNode(
15371539

15381540
// Update the stats.
15391541
// Best move.
1542+
// If update_parent_bounds was set, we just adjusted bounds on the
1543+
// previous loop or there was no previous loop, so if n is a terminal, it
1544+
// just became that way and could be a candidate for changing the current
1545+
// best edge. Otherwise a visit can only change best edge if its to an edge
1546+
// that isn't already the best and the new n is equal or greater to the old
1547+
// n.
15401548
if (p == search_->root_node_ &&
1541-
search_->current_best_edge_.GetN() <= n->GetN()) {
1549+
(old_update_parent_bounds && n->IsTerminal() ||
1550+
n != search_->current_best_edge_.node() &&
1551+
search_->current_best_edge_.GetN() <= n->GetN())) {
15421552
search_->current_best_edge_ =
15431553
search_->GetBestChildNoTemperature(search_->root_node_, 0);
15441554
}

0 commit comments

Comments
 (0)