예제 #1
0
def human_play(stdscr, game_class):
    player = DebugHumanPlayer(stdscr)
    console = ConsoleDebugObserver(stdscr)
    replay_server = ReplayServer(int(os.environ.get("GAME_SERVER_PORT", 7000)))

    game = game_class(player)
    game.add_observer(console)
    game.add_observer(replay_server)

    player.setup(game)
    console.setup(game)
    replay_server.run_as_background()

    while True:
        game.play()
def agent_play(game_class, agent_player):
    replay_server = ReplayServer(int(os.environ.get("GAME_SERVER_PORT", 7000)))

    game = game_class(agent_player)
    game.add_observer(replay_server)
    game.add_observer(agent_player)

    replay_server.run_as_background()

    agent_player.effective_action_index_list = game.effective_actions()

    while True:
        replay_server.info = ["e-Greedy=%s" % agent_player.use_greedy] + agent_player.agent_model.info_list()
        try:
            game.play()
            if game.play_id % 10 == 0:
                agent_player.use_greedy = not agent_player.use_greedy
        except QuitGameException as e:
            agent_player.load_model_parameters()
            print e