Skip to content

Instantly share code, notes, and snippets.

@masouduut94
Created October 23, 2020 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masouduut94/ae58380344b6812c1a776d17dc9c24d5 to your computer and use it in GitHub Desktop.
Save masouduut94/ae58380344b6812c1a776d17dc9c24d5 to your computer and use it in GitHub Desktop.
def search(self, time_budget: int) -> None:
"""
Search and update the search tree for a
specified amount of time in seconds.
"""
start_time = clock()
num_rollouts = 0
# do until we exceed our time budget
while clock() - start_time < time_budget:
node, state = self.select_node()
turn = state.turn()
outcome = self.roll_out(state)
self.backup(node, turn, outcome)
num_rollouts += 1
run_time = clock() - start_time
node_count = self.tree_size()
self.run_time = run_time
self.node_count = node_count
self.num_rollouts = num_rollouts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment