def make_env(stack=True, scale_rew=True):
    """
    Create an environment with some standard wrappers.
    """
    env = make(game='SonicTheHedgehog2-Genesis',
               state='MetropolisZone.Act3',
               bk2dir='movies_tuned/')
    env = retro_contest.Monitor(env,
                                os.path.join('results', 'monitor_tuned.csv'),
                                os.path.join('results', 'log_tuned.csv'))
    env = SonicDiscretizer(env, noop=True)
    if scale_rew:
        env = RewardScaler(env)
    env = WarpFrame(env)
    if stack:
        env = FrameStack(env, 4)
    return env
def make(game, state=retro.STATE_DEFAULT, discrete_actions=False, bk2dir=None,monitordir=None, scenario='contest'):
    use_restricted_actions = retro.ACTIONS_FILTERED
    if discrete_actions:
        use_restricted_actions = retro.ACTIONS_DISCRETE
    try:
        #env = retro.make(game, state, scenario='contest', use_restricted_actions=use_restricted_actions)
        env = retro.make(game, state, scenario=scenario, use_restricted_actions=use_restricted_actions)
    except Exception:
        env = retro.make(game, state, use_restricted_actions=use_restricted_actions)
    if bk2dir:
        env.auto_record(bk2dir)
    #added this
    if monitordir:
        env = retro_contest.Monitor(env, os.path.join(monitordir, 'monitor.csv'), os.path.join(monitordir, 'log.csv'))
    env = retro_contest.StochasticFrameSkip(env, n=4, stickprob=0.25)
    env = gym.wrappers.TimeLimit(env, max_episode_steps=4500)
    #env.serve(timestep_limit=10000, ignore_reset=True)
    return env
def make(game,
         state,
         bk2dir=None,
         monitordir=None,
         discrete_actions=False,
         socketdir='tmp/sock'):
    if bk2dir:
        os.makedirs(bk2dir, exist_ok=True)
    env = retro_contest.local.make(game,
                                   state,
                                   discrete_actions=discrete_actions,
                                   bk2dir=bk2dir)
    if monitordir:
        env = retro_contest.Monitor(env, os.path.join(monitordir,
                                                      'monitor.csv'),
                                    os.path.join(monitordir, 'log.csv'))
    env = grs.RemoteEnvWrapper(env, socketdir)
    return env
Exemple #4
0
def make(game,
         state=retro.State.DEFAULT,
         discrete_actions=False,
         bk2dir=None,
         monitordir=None,
         scenario='scenario'):
    use_restricted_actions = retro.Actions.FILTERED  #retro.ACTIONS_FILTERED
    if discrete_actions:
        use_restricted_actions = retro.Actions.DISCRETE  #retro.ACTIONS_DISCRETE
    try:
        #env = retro.make(game, state, scenario='contest', use_restricted_actions=use_restricted_actions)
        env = retro.make(game,
                         state,
                         scenario=scenario,
                         use_restricted_actions=use_restricted_actions)
    except Exception:
        env = retro.make(game,
                         state,
                         use_restricted_actions=use_restricted_actions)
    if bk2dir:
        env.auto_record(bk2dir)
    #added this
    if monitordir:
        time_int = int(time.time())
        env = retro_contest.Monitor(
            env, os.path.join(monitordir, 'monitor_{}.csv'.format(time_int)),
            os.path.join(monitordir, 'log_{}.csv'.format(time_int)))
    #bust a move
    #env = retro_contest.StochasticFrameSkip(env, n=6, stickprob=0.0) #n=10, did some analysis on this
    #contra
    env = retro_contest.StochasticFrameSkip(env, n=4, stickprob=0.0)
    #sonic
    #env = retro_contest.StochasticFrameSkip(env, n=4, stickprob=0.25)
    env = gym.wrappers.TimeLimit(env, max_episode_steps=8000)
    #env.serve(timestep_limit=10000, ignore_reset=True)
    return env