Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. def get_available_actions(state):
  2. # TODO <1>
  3. i = -1
  4. ls = []
  5. for x in state[0]:
  6. i += 1
  7. if 0 in x:
  8. ls.append(i)
  9. return ls
  10.  
  11. def magic_func(parent, child, c):
  12. return child[Q] / child[N] + c * sqrt(2 * log(parent[N]) / child[N])
  13.  
  14. # Funcție ce alege o acțiune dintr-un nod
  15. def select_action(node, c = CP):
  16. # TODO <2>
  17. # Se caută acțiunea a care maximizează expresia:
  18. # Q_a / N_a + c * sqrt(2 * log(N_node) / N_a)
  19. 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