Skip to content

Instantly share code, notes, and snippets.

@davidADSP
Created December 1, 2019 16:29
Show Gist options
  • Select an option

  • Save davidADSP/5b9ac56aecf2664fc92b8a92ae4251a6 to your computer and use it in GitHub Desktop.

Select an option

Save davidADSP/5b9ac56aecf2664fc92b8a92ae4251a6 to your computer and use it in GitHub Desktop.
class Node(object):
def __init__(self, prior: float):
self.visit_count = 0
self.to_play = -1
self.prior = prior
self.value_sum = 0
self.children = {}
self.hidden_state = None
self.reward = 0
def expanded(self) -> bool:
return len(self.children) > 0
def value(self) -> float:
if self.visit_count == 0:
return 0
return self.value_sum / self.visit_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment