-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atari_Environment.py
28 lines (25 loc) · 883 Bytes
/
Atari_Environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from gym import Wrapper, spaces
from Open_AI_Wrappers import *
def make_atari_game(env_id, max_episode_steps=None):
env = gym.make(env_id)
env.frameskip = 1
env = NoopResetEnv(env, noop_max=30)
env = MaxAndSkipEnv(env, skip=4)
if max_episode_steps is not None:
env = TimeLimit(env, max_episode_steps=max_episode_steps)
env = wrap_deepmind(env)
return env
def wrap_deepmind(env, episode_life=True, clip_rewards=True, frame_stack=True, scale=True):
"""Configure environment for DeepMind-style Atari """
if episode_life:
env = EpisodicLifeEnv(env)
if 'FIRE' in env.unwrapped.get_action_meanings():
env = FireResetEnv(env)
env = WarpFrame(env)
if scale:
env = ScaledFloatFrame(env)
if clip_rewards:
env = ClipRewardEnv(env)
if frame_stack:
env = FrameStack(env, 4)
return env