Esempio n. 1
0
        draw = False
        while game.check_game_over() == 0:
            clone = game.clone()
            # Player 1
            if step % 2 != 0:
                predicted_action, temp_children, temp_moves = tree_search_1.search(
                    game.clone())
                temp_policy = get_tree_policy(temp_children, temp_moves)
                store.update_store([game.clone().state, temp_policy, 0],
                                   player1=True)
                game.play_action(predicted_action)
                print('P1 Non Chain -> ', end='\t')
                print(predicted_action)
                if clone.if_attack_move(predicted_action):
                    while game.attack_move_available(
                            game.remove_except_current(predicted_action)):
                        predicted_action, temp_children, temp_moves = tree_search_1.search(
                            game.clone(),
                            chain_move=True,
                            action=predicted_action)
                        temp_policy = get_tree_policy(temp_children,
                                                      temp_moves)
                        store.update_store(
                            [game.clone().state, temp_policy, 0], player1=True)
                        game.play_action(predicted_action)
                        print('P1 Chain -> ', end='\t')
                        print(predicted_action)

            # Player 2
            else:
                predicted_action, temp_children, temp_moves = tree_search_2.search(