Skip to content

Commit

Permalink
Skip updating value if the node has become terminal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mardak committed Mar 29, 2019
1 parent 46bb54b commit 5f9c77e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mcts/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ void Node::CancelScoreUpdate(int multivisit) {
}

void Node::FinalizeScoreUpdate(float v, float d, int multivisit) {
// Recompute Q.
q_ += multivisit * (v - q_) / (n_ + multivisit);
d_ += multivisit * (d - d_) / (n_ + multivisit);
// Skip updating value if the node has become terminal.
if (!is_terminal_) {
q_ += multivisit * (v - q_) / (n_ + multivisit);
d_ += multivisit * (d - d_) / (n_ + multivisit);
}

// If first visit, update parent's sum of policies visited at least once.
if (n_ == 0 && parent_ != nullptr) {
Expand Down

0 comments on commit 5f9c77e

Please sign in to comment.