예제 #1
0
def make():
    from tartist.app.rl.simulator import automake
    game = automake('custom.CustomLavaWorldTaxiEnv',
                    dense_reward=True,
                    use_coord=True)
    # you need to restart your game here
    game.restart()
    return game
예제 #2
0
def main(args, controller):
    if args.output is None:
        args.output = '{}.conf.py'.format(args.gamename)

    if osp.isfile(args.output):
        logger.warn('Output config file already exists: {}.'.format(
            args.output))
        if not yes_or_no('Do you want to overwrite?', default='no'):
            controller.quit()
            return

    game = automake(args.gamename)
    game.restart()

    action_space = game.action_space
    assert isinstance(action_space, DiscreteActionSpace)

    action_names = action_space.action_meanings
    action_keys = []

    logger.critical('All action names: {}'.format(action_names))
    logger.critical('Start recording...')

    img = image.resize_minmax(game.current_state,
                              *args.winsize,
                              interpolation='NEAREST')
    controller.update_title(args.gamename)
    controller.update(img)

    for i in range(len(action_names)):
        name = action_names[i]
        logger.info('{}-th action, name={}, waiting...'.format(i, name))
        action = controller.get_last_key()
        action_keys.append(action)
        logger.info('{}-th action, name={}, key={}, done.'.format(
            i, name, repr(action)))
    logger.critical('Recording end.')

    logger.info('Recoding quit action key')
    quit_key = controller.get_last_key()
    logger.info('quit action, key={}, done.'.format(repr(quit_key)))
    controller.quit()

    with open(args.output, 'w') as f:
        f.write('# -*- coding:utf8 -*-\n\n')
        f.write(__automake_format__.format(args.gamename))
        f.write("name = '{}'\n".format(args.gamename))
        f.write("action_names = {}\n".format(repr(action_names)))
        f.write("action_keys = {}\n".format(repr(action_keys)))
        f.write("quit_action_key = {}\n".format(repr(quit_key)))
        f.write("\n")
        f.write("# default min size is a tuple (min_dim, max_dim)\n")
        f.write("default_winsize = (600, 800)\n")
        f.write("# ignore no-action (action=0) in logging\n")
        f.write("mute_noaction = True\n")
        f.write("\n")
    logger.critical('Cfg file written to {}'.format(args.output))
예제 #3
0
def make():
    from tartist.app.rl.simulator import automake
    game = automake('gym.Enduro-v0')
    # you need to restart your game here
    game.restart()
    return game
def make():
    from tartist.app.rl.simulator import automake
    game = automake('custom.MazeEnv', map_size=15, visible_size=7)
    game.restart()
    return game
예제 #5
0
def make():
    from tartist.app.rl.simulator import automake
    game = automake('custom.MazeEnv')
    # you need to restart your game here
    game.restart()
    return game