예제 #1
0
파일: peto.py 프로젝트: mrkvost/quoridor
def tf_play(colors_on, special):
    game = ConsoleGame(console_colors=colors_on, special_chars=special)

    # INIT TENSORFLOW
    session = tf.Session()
    ann = TFPlayer(game, session)
    filename = ann.last_model_filename()
    if filename is None:
        raise Exception('Could not load ANN data.')
    ann.load(filename)

    kwargs = {
        'messages': game.messages,
        'game_controls': game.GAME_CONTROLS,
        'fail_callback': game.wrong_human_move,
    }
    hp = HumanPlayer(game, **kwargs)
    context = QuoridorContext(game)
    get_players = players_creator_factory(hp, 'human', ann)
    context.reset(players=get_players())

    while not context.is_terminal:
        game.display_on_console(context)
        context.current['player'](context)
    game.display_on_console(context)

    session.close()
예제 #2
0
파일: peto.py 프로젝트: mrkvost/quoridor
def measure(colors_on, special, opponent_type):
    game = ConsoleGame(console_colors=colors_on, special_chars=special)
    opponent = OPPONENTS[opponent_type](game)

    # INIT TENSORFLOW
    # session = tf.Session()
    # ann = TFPlayer(game, session)
    # saver = tf.train.Saver()
    # saver.restore(session, 'model.ckpt')
    # print 'tfplayer input layer size:', ann.input
    # print 'x'*80

    ann = RandomPlayerWithPath(game)

    context = QuoridorContext(game)
    while True:
        get_players = players_creator_factory(opponent, opponent_type, ann)
        context.reset(players=get_players())
        while not context.is_terminal:
            context.current['player'](context)
        game.display_on_console(context)
        break