def _test_state(self, state):
     agent = CustomPlayer(state.ply_count % 2)
     action = fork_get_action(state, agent, self.time_limit)
     self.assertTrue(action in state.actions(), dedent("""\
         Your agent did not call self.queue.put() with a valid action \
         within {} milliseconds from state {}
     """).format(self.time_limit, state))
예제 #2
0
def build_tree(state, book, depth=5):
    if depth <= 0 or state.terminal_test():
        return -simulate(state)

    agent = CustomPlayer(state.player())
    action = agent.minimax_with_alpha_beta_pruning(state, depth)
    reward = build_tree(state.result(action), book, depth - 1)

    book[state][action] += reward
    return -reward