Skip to content

Commit

Permalink
Don't discard games that are in positions that are already done. (#1048)
Browse files Browse the repository at this point in the history
* Don't discard games that are in positions that are already done.

* Minor optimization.

* Minor tweak for consistency with surrounding code.
  • Loading branch information
Tilps committed Dec 31, 2019
1 parent 9321877 commit a1b23ac
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/selfplay/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,18 @@ void SelfPlayGame::Play(int white_threads, int black_threads, bool training,
kMinimumAllowedVistsId.GetId())) {
break;
}
auto move_list_to_discard = GetMoves();
move_list_to_discard.push_back(move);
options_[idx].discarded_callback(move_list_to_discard);
PositionHistory history_copy = tree_[idx]->GetPositionHistory();
Move move_for_history = move;
if (tree_[idx]->IsBlackToMove()) {
move_for_history.Mirror();
}
history_copy.Append(move_for_history);
// Ensure not to discard games that are already decided.
if (history_copy.ComputeGameResult() == GameResult::UNDECIDED) {
auto move_list_to_discard = GetMoves();
move_list_to_discard.push_back(move);
options_[idx].discarded_callback(move_list_to_discard);
}
search_->ResetBestMove();
}
// Add best move to the tree.
Expand Down

0 comments on commit a1b23ac

Please sign in to comment.