Skip to content

Instantly share code, notes, and snippets.

@DanielSlater
Created October 21, 2017 20:27
Show Gist options
  • Save DanielSlater/7d245dad115f8e2a4a626d9e794052f5 to your computer and use it in GitHub Desktop.
Save DanielSlater/7d245dad115f8e2a4a626d9e794052f5 to your computer and use it in GitHub Desktop.
if all((state in state_samples) for _, state in move_states):
log_total_samples = math.log(sum(state_samples[s] for s in move_states.values()))
move, state = max(move_states,
key=lambda _, s:upper_confidence_bounds(state_results[s],state_samples[s], log_total_samples))
else:
move = random.choice(list(move_states.keys()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment