Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_available_actions(state):
- # TODO <1>
- i = -1
- ls = []
- for x in state[0]:
- i += 1
- if 0 in x:
- ls.append(i)
- return ls
- def magic_func(parent, child, c):
- return child[Q] / child[N] + c * sqrt(2 * log(parent[N]) / child[N])
- # Funcție ce alege o acțiune dintr-un nod
- def select_action(node, c = CP):
- # TODO <2>
- # Se caută acțiunea a care maximizează expresia:
- # Q_a / N_a + c * sqrt(2 * log(N_node) / N_a)
- return reduce(lambda x, y: x[0] if magic_func(node, x[1], c) > magic_func(node, y[1], c) else y[0], list(node[ACTIONS].items()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement