Skip to content

Commit

Permalink
added assertion of 'NoFrameskip' in AtariPreprocessing (openai#1725)
Browse files Browse the repository at this point in the history
* added assertion of noframeskip in atari pre-proecessing

* - corrected frameskipping assertion
- added non-op assertion as well
  • Loading branch information
koulanurag authored and pzhokhov committed Nov 4, 2019
1 parent 7a97c89 commit 21bd4f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gym/wrappers/atari_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def __init__(self, env, noop_max=30, frame_skip=4, screen_size=84, terminal_on_l
super().__init__(env)
assert frame_skip > 0
assert screen_size > 0

assert noop_max >= 0
if frame_skip > 1:
assert 'NoFrameskip' in env.spec.id, 'disable frame-skipping in the original env. for more than one' \
' frame-skip as it will be done by the wrapper'
self.noop_max = noop_max
assert env.unwrapped.get_action_meanings()[0] == 'NOOP'

Expand Down
2 changes: 1 addition & 1 deletion gym/wrappers/test_gray_scale_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pytest.importorskip('atari_py')
pytest.importorskip('cv2')

@pytest.mark.parametrize('env_id', ['Pong-v0', 'SpaceInvaders-v0'])
@pytest.mark.parametrize('env_id', ['PongNoFrameskip-v0', 'SpaceInvadersNoFrameskip-v0'])
@pytest.mark.parametrize('keep_dim', [True, False])
def test_gray_scale_observation(env_id, keep_dim):
gray_env = AtariPreprocessing(gym.make(env_id), screen_size=84, grayscale_obs=True)
Expand Down
2 changes: 1 addition & 1 deletion gym/wrappers/test_resize_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@pytest.mark.skipif(atari_py is None, reason='Only run this test when atari_py is installed')
@pytest.mark.parametrize('env_id', ['Pong-v0', 'SpaceInvaders-v0'])
@pytest.mark.parametrize('env_id', ['PongNoFrameskip-v0', 'SpaceInvadersNoFrameskip-v0'])
@pytest.mark.parametrize('shape', [16, 32, (8, 5), [10, 7]])
def test_resize_observation(env_id, shape):
env = gym.make(env_id)
Expand Down

0 comments on commit 21bd4f3

Please sign in to comment.