Ejemplo n.º 1
0
from debug_log import DebugLog

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-m", "--model_path")
    args = parser.parse_args()

    env = CatchBall()
    agent = DQNAgent(env.enable_actions, env.name)
    agent.load_model(args.model_path)

    env.reset_board_status()
    env.set_test_game()

    # 1ゲーム内の処理開始地点
    while env.is_playable() is True:
        env.print_board()
        env.test_player_play()

        state = env.observe()

        while True is True:
            action = agent.select_action(state, 0.0)
            hand_result = env.test_ai_play(action)
            if hand_result == "ok":
                break
            elif hand_result == "ng":
                x = int(action % 8)
                y = int(action / 8)
                DebugLog.error(str(action) + ":" + str(x) + ":" + str(y))
                pass
Ejemplo n.º 2
0
    env = CatchBall()
    agent = DQNAgent(env.enable_actions, env.name)
    total_result_log = ""

    for e in range(n_game):
        # るーぷ開始地点
        frame = 0
        win = 0
        loss = 0.0
        Q_max = 0.0
        env.reset_board_status()
        env.set_new_game()
        state_after = env.observe()

        # 1ゲーム内の処理開始地点
        while env.is_playable() is True:
            # print "*********************************************************************************"

            state_before = copy.deepcopy(state_after)

            # 自分の手がOKになるまでループ(置けないところに置く可能性がある為)
            while True is True:
                env.is_available()

                # 手を選ばせる。盤面情報と手のブレ率(random)を与える
                # hand_result = env.random_play()
                action_t = agent.select_action(state_before, agent.exploration)
                hand_result = env.learning_play(action_t)

                if hand_result == "ok":
                    break