Skip to content

Commit

Permalink
Move legacy Atari environments -> ale-py (openai#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseFarebro authored Sep 22, 2021
1 parent ae01834 commit 5f89135
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 175 deletions.
1 change: 0 additions & 1 deletion docs/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ and are namespaced with `ALE`. For example, the `v5` environments can be include

```python
import gym
import ale_py

env = gym.make('ALE/SpaceInvaders-v5')
```
Expand Down
161 changes: 0 additions & 161 deletions gym/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,167 +620,6 @@ def _merge(a, b):
max_episode_steps=100,
)

# Atari
# ----------------------------------------

for game in [
"adventure",
"air_raid",
"alien",
"amidar",
"assault",
"asterix",
"asteroids",
"atlantis",
"bank_heist",
"battle_zone",
"beam_rider",
"berzerk",
"bowling",
"boxing",
"breakout",
"carnival",
"centipede",
"chopper_command",
"crazy_climber",
"defender",
"demon_attack",
"double_dunk",
"elevator_action",
"enduro",
"fishing_derby",
"freeway",
"frostbite",
"gopher",
"gravitar",
"hero",
"ice_hockey",
"jamesbond",
"journey_escape",
"kangaroo",
"krull",
"kung_fu_master",
"montezuma_revenge",
"ms_pacman",
"name_this_game",
"phoenix",
"pitfall",
"pong",
"pooyan",
"private_eye",
"qbert",
"riverraid",
"road_runner",
"robotank",
"seaquest",
"skiing",
"solaris",
"space_invaders",
"star_gunner",
"tennis",
"time_pilot",
"tutankham",
"up_n_down",
"venture",
"video_pinball",
"wizard_of_wor",
"yars_revenge",
"zaxxon",
]:
for obs_type in ["rgb", "ram"]:
# space_invaders should yield SpaceInvaders-v0 and SpaceInvaders-ram-v0
name = "".join([g.capitalize() for g in game.split("_")])
if obs_type == "ram":
name = "{}-ram".format(name)

nondeterministic = False
if game == "elevator_action" and obs_type == "ram":
# ElevatorAction-ram-v0 seems to yield slightly
# non-deterministic observations about 10% of the time. We
# should track this down eventually, but for now we just
# mark it as nondeterministic.
nondeterministic = True

default_kwargs = {
"game": game,
"obs_type": obs_type,
"repeat_action_probability": 0.0,
"full_action_space": False,
"frameskip": (2, 5),
}

register(
id="{}-v0".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={
**default_kwargs,
"repeat_action_probability": 0.25,
},
max_episode_steps=10000,
nondeterministic=nondeterministic,
)

register(
id="{}-v4".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={**default_kwargs},
max_episode_steps=100000,
nondeterministic=nondeterministic,
)

# Standard Deterministic (as in the original DeepMind paper)
if game == "space_invaders":
frameskip = 3
else:
frameskip = 4

# Use a deterministic frame skip.
register(
id="{}Deterministic-v0".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={
**default_kwargs,
"frameskip": frameskip,
"repeat_action_probability": 0.25,
},
max_episode_steps=100000,
nondeterministic=nondeterministic,
)

register(
id="{}Deterministic-v4".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={**default_kwargs, "frameskip": frameskip},
max_episode_steps=100000,
nondeterministic=nondeterministic,
)

register(
id="{}NoFrameskip-v0".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={
**default_kwargs,
"frameskip": 1,
"repeat_action_probability": 0.25,
}, # A frameskip of 1 means we get every frame
max_episode_steps=frameskip * 100000,
nondeterministic=nondeterministic,
)

# No frameskip. (Atari has no entropy source, so these are
# deterministic environments.)
register(
id="{}NoFrameskip-v4".format(name),
entry_point="ale_py.gym:ALGymEnv",
kwargs={
**default_kwargs,
"frameskip": 1,
}, # A frameskip of 1 means we get every frame
max_episode_steps=frameskip * 100000,
nondeterministic=nondeterministic,
)


# Unit test
# ---------

Expand Down
6 changes: 3 additions & 3 deletions gym/envs/tests/spec_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def should_skip_env_spec_for_tests(spec):
):
return True
try:
import ale_py
import gym.envs.atari
except ImportError:
if ep.startswith("ale_py.gym"):
if ep.startswith("gym.envs.atari"):
return True
try:
import Box2D
Expand All @@ -40,7 +40,7 @@ def should_skip_env_spec_for_tests(spec):
"GoEnv" in ep
or "HexEnv" in ep
or (
ep.startswith("ale_py.gym")
ep.startswith("gym.envs.atari")
and not spec.id.startswith("Pong")
and not spec.id.startswith("Seaquest")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import pytest

pytest.importorskip("gym.envs.atari")

from gym.envs.registration import registry

from itertools import product
Expand Down
2 changes: 1 addition & 1 deletion gym/wrappers/test_atari_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gym.wrappers import AtariPreprocessing
import pytest

pytest.importorskip("ale_py")
pytest.importorskip("gym.envs.atari")


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion gym/wrappers/test_frame_stack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

pytest.importorskip("ale_py")
pytest.importorskip("gym.envs.atari")

import numpy as np
import gym
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 @@ -6,7 +6,7 @@
from gym.wrappers import GrayScaleObservation
from gym.wrappers import AtariPreprocessing

pytest.importorskip("ale_py")
pytest.importorskip("gym.envs.atari")
pytest.importorskip("cv2")


Expand Down
8 changes: 1 addition & 7 deletions gym/wrappers/test_resize_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
import gym
from gym.wrappers import ResizeObservation

try:
import ale_py
except ImportError:
ale_py = None
pytest.importorskip("gym.envs.atari")


@pytest.mark.skipif(
ale_py is None, reason="Only run this test when ale_py is installed"
)
@pytest.mark.parametrize(
"env_id", ["PongNoFrameskip-v0", "SpaceInvadersNoFrameskip-v0"]
)
Expand Down

0 comments on commit 5f89135

Please sign in to comment.