Skip to content

Instantly share code, notes, and snippets.

@davidADSP
Created December 1, 2019 20:28
Show Gist options
  • Save davidADSP/19629c30793d2922cf74ad3df0e4ab2e to your computer and use it in GitHub Desktop.
Save davidADSP/19629c30793d2922cf74ad3df0e4ab2e to your computer and use it in GitHub Desktop.
# At the end of a simulation, we propagate the evaluation all the way up the
# tree to the root.
def backpropagate(search_path: List[Node], value: float, to_play: Player,
discount: float, min_max_stats: MinMaxStats):
for node in search_path:
node.value_sum += value if node.to_play == to_play else -value
node.visit_count += 1
min_max_stats.update(node.value())
value = node.reward + discount * value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment