Skip to content

Commit

Permalink
Remove AtariEnv in favour of official ALE Python package (openai#2348)
Browse files Browse the repository at this point in the history
* Remove AtariEnv in favour of official ALE Python

* More robust frame stacking test case

* Atari documentation update
  • Loading branch information
JesseFarebro authored Sep 11, 2021
1 parent 263a341 commit f6742ea
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 300 deletions.
27 changes: 16 additions & 11 deletions docs/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@ It's worth browsing through both.

### Atari

The Atari environments are a variety of Atari video games. If you didn't
do the full install, you can install dependencies via `pip install -e
'.[atari]'` (you'll need `cmake` installed) and then get started as
follows:

The Atari environments are provided by the [Arcade Learning Environment](https://github.com/mgbellemare/Arcade-Learning-Environment) (ALE).
If you didn't do the full install, you can install dependencies via `pip install -e '.[atari]'` which will install `ale-py`.
You can then create any of the legacy Atari environments as such:
``` python
import gym

env = gym.make('SpaceInvaders-v4')
env.reset()
env.render()
```

This will install `atari-py`, which automatically compiles the [Arcade
Learning Environment](https://github.com/mgbellemare/Arcade-Learning-Environment#:~:text=The%20Arcade%20Learning%20Environment%20(ALE)%20is%20a%20simple%20object%2D,of%20emulation%20from%20agent%20design.). This
can take quite a while (a few minutes on a decent laptop), so just be
prepared.
Newer versions of the Atari environments live in the [ALE](https://github.com/mgbellemare/Arcade-Learning-Environment) repository
and are namespaced with `ALE`. For example, the `v5` environments can be included as such:

```python
import gym
import ale_py

env = gym.make('ALE/SpaceInvaders-v5')
```

Note: ROMs are not distributed by the ALE but tools are provided in the ALE to manage ROMs.
Please see the project's documentation on importing ROMs.

### Box2d

Expand Down
15 changes: 7 additions & 8 deletions gym/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ def _merge(a, b):
# Atari
# ----------------------------------------

# # print ', '.join(["'{}'".format(name.split('.')[0]) for name in atari_py.list_games()])
for game in [
"adventure",
"air_raid",
Expand Down Expand Up @@ -678,7 +677,7 @@ def _merge(a, b):
"yars_revenge",
"zaxxon",
]:
for obs_type in ["image", "ram"]:
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":
Expand All @@ -694,7 +693,7 @@ def _merge(a, b):

register(
id="{}-v0".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={
"game": game,
"obs_type": obs_type,
Expand All @@ -706,7 +705,7 @@ def _merge(a, b):

register(
id="{}-v4".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={"game": game, "obs_type": obs_type},
max_episode_steps=100000,
nondeterministic=nondeterministic,
Expand All @@ -721,7 +720,7 @@ def _merge(a, b):
# Use a deterministic frame skip.
register(
id="{}Deterministic-v0".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={
"game": game,
"obs_type": obs_type,
Expand All @@ -734,15 +733,15 @@ def _merge(a, b):

register(
id="{}Deterministic-v4".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={"game": game, "obs_type": obs_type, "frameskip": frameskip},
max_episode_steps=100000,
nondeterministic=nondeterministic,
)

register(
id="{}NoFrameskip-v0".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={
"game": game,
"obs_type": obs_type,
Expand All @@ -757,7 +756,7 @@ def _merge(a, b):
# deterministic environments.)
register(
id="{}NoFrameskip-v4".format(name),
entry_point="gym.envs.atari:AtariEnv",
entry_point="ale_py.gym:ALGymEnv",
kwargs={
"game": game,
"obs_type": obs_type,
Expand Down
1 change: 0 additions & 1 deletion gym/envs/atari/__init__.py

This file was deleted.

253 changes: 0 additions & 253 deletions gym/envs/atari/atari_env.py

This file was deleted.

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 atari_py
import ale_py
except ImportError:
if ep.startswith("gym.envs.atari"):
if ep.startswith("ale_py.gym"):
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("gym.envs.atari")
ep.startswith("ale_py.gym")
and not spec.id.startswith("Pong")
and not spec.id.startswith("Seaquest")
)
Expand Down
Loading

0 comments on commit f6742ea

Please sign in to comment.