def wrap_demon_attack_test(env, stack_frames=4):
    """Apply a common set of wrappers for Atari games."""
    assert 'NoFrameskip' in env.spec.id
    #if episodic_life:
    #env = ptanwrap.EpisodicLifeEnv(env)
    env = ptanwrap.NoopResetEnv(env, noop_max=30)
    env = ptanwrap.MaxAndSkipEnv(env, skip=4)
    if 'FIRE' in env.unwrapped.get_action_meanings():
        env = ptanwrap.FireResetEnv(env)
    env = ptanwrap.ProcessFrame84(env)
    env = ptanwrap.ImageToPyTorch(env)
    env = ptanwrap.FrameStack(env, stack_frames)
    #env = ptanwrap.ClippedRewardsWrapper(env)
    return env
def wrap_atlantis(env,
                  stack_frames=4,
                  episodic_life=False,
                  reward_reshaping=True):
    """Apply a common set of wrappers for Atari games."""
    assert 'NoFrameskip' in env.spec.id
    if episodic_life:
        env = ptanwrap.EpisodicLifeEnv(env)
    env = ptanwrap.NoopResetEnv(env, noop_max=30)
    env = ptanwrap.MaxAndSkipEnv(env, skip=4)
    if 'FIRE' in env.unwrapped.get_action_meanings():
        env = ptanwrap.FireResetEnv(env)
    env = AtlantisResizeAndRecolorFrame(env)
    env = ptanwrap.ImageToPyTorch(env)
    env = ptanwrap.FrameStack(env, stack_frames)
    if reward_reshaping:
        env = ptanwrap.ClippedRewardsWrapper(env)
    return env
def wrap_pacman(env,
                stack_frames=4,
                episodic_life=True,
                reward_reshaping=True,
                recolor_eatable_ghosts=True):
    """Apply a common set of wrappers for Atari games."""
    assert 'NoFrameskip' in env.spec.id
    if episodic_life:
        env = ptanwrap.EpisodicLifeEnv(env)
    #Pacman skips 90 frames at end of life. This skips a random amount up to 90
    env = ptanwrap.NoopResetEnv(env, noop_max=90)
    env = ptanwrap.MaxAndSkipEnv(env, skip=4)
    if 'FIRE' in env.unwrapped.get_action_meanings():
        env = ptanwrap.FireResetEnv(env)
    env = PacmanResizeAndRecolorFrame(env, recolor_eatable_ghosts)
    env = ptanwrap.ImageToPyTorch(env)
    env = ptanwrap.FrameStack(env, stack_frames)
    if reward_reshaping:
        env = PacmanRewardManager(env)
    return env
Beispiel #4
0
def wrap_dqn_light(env,
                   stack_frames=2,
                   skip=4,
                   max_episode_steps=None,
                   episodic_life=True,
                   reward_clipping=True):
    """Apply a lightweight wrapper for faster DQN training."""
    assert "NoFrameskip" in env.spec.id
    if episodic_life:
        env = wrappers.EpisodicLifeEnv(env)
    env = SkipEnv(env, skip=skip)
    if max_episode_steps is not None:
        env._max_episode_steps = max_episode_steps
    if 'FIRE' in env.unwrapped.get_action_meanings():
        env = wrappers.FireResetEnv(env)
    env = WarpFrame(env)
    env = wrappers.ImageToPyTorch(env)
    env = wrappers.FrameStack(env, stack_frames)
    if reward_clipping:
        env = wrappers.ClippedRewardsWrapper(env)
    return env