added assertion of 'NoFrameskip' in AtariPreprocessing (#1725)

* added assertion of noframeskip in atari pre-proecessing

* - corrected frameskipping assertion
- added non-op assertion as well
This commit is contained in:
Anurag Koul
2019-11-04 09:48:21 -08:00
committed by pzhokhov
parent 7a97c89b44
commit 21bd4f304b
3 changed files with 6 additions and 3 deletions

View File

@@ -40,7 +40,10 @@ class AtariPreprocessing(gym.Wrapper):
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'

View File

@@ -8,7 +8,7 @@ from gym.wrappers import AtariPreprocessing
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)

View File

@@ -9,7 +9,7 @@ except ImportError:
@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)