Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add atari environments #57

Merged
merged 23 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2e527d6
Add auto-resetting atari environments
dfilan Aug 24, 2022
e57612c
Improve documentation, reduce testing time for atari envs
dfilan Aug 25, 2022
8f1d3a2
Add atari dependencies for testing
dfilan Aug 25, 2022
5d8c440
Simplify boolean check
dfilan Aug 25, 2022
9766301
Demand result of env.seed be a list or tuple
dfilan Aug 25, 2022
966d6ca
Merge branch 'atari_envs' of github.com:HumanCompatibleAI/seals into …
dfilan Aug 25, 2022
af70b75
Add documentation for why atari is treated differently in tests
dfilan Aug 25, 2022
e5162d7
clarify why we check that env.seed returns a list or tuple
dfilan Aug 25, 2022
cbef7d2
Parametrize test_seed
dfilan Aug 25, 2022
64203c4
Explain why Bowling and NameThisGame are different
dfilan Aug 25, 2022
e48d417
Tidy code, clarify README
dfilan Aug 30, 2022
ab9ac74
Pull atari envs from gym registry, rather than hard-coding
dfilan Aug 31, 2022
50b473b
Fix formatting of test_envs
dfilan Aug 31, 2022
1e37723
Fix spelling of MuJoCo
dfilan Sep 3, 2022
27d9cdb
Fix Atari capitalization
dfilan Sep 3, 2022
40c1637
Remove TODO
dfilan Sep 3, 2022
ef0faa9
Merge branch 'atari_envs' of github.com:HumanCompatibleAI/seals into …
dfilan Sep 3, 2022
5deca1d
Simplify checking that filter isn't empty
dfilan Sep 3, 2022
9b44938
Add documentation to helper methods
dfilan Sep 3, 2022
425c8d8
Don't unnecessarily use list where tuple will do
dfilan Sep 3, 2022
b1e70bc
Move atari registration logic to atari.py
dfilan Sep 3, 2022
0e50cd0
Add type annotations
dfilan Sep 6, 2022
000ca5c
Fix capitalization of 'Atari'
dfilan Sep 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ There are two types of environments in *seals*:

- **Diagnostic Tasks** which test individual facets of algorithm performance in isolation.
- **Renovated Environments**, adaptations of widely-used benchmarks such as MuJoCo continuous
control tasks to be suitable for specification learning benchmarks. In particular, we remove
any side-channel sources of reward information.
control tasks and Atari games to be suitable for specification learning benchmarks. In particular,
we remove any side-channel sources of reward information.

*seals* is under active development and we intend to add more categories of tasks soon.

Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def get_readme() -> str:
"sphinx-rtd-theme",
"sphinxcontrib-napoleon",
]
ATARI_REQUIRE = [
"opencv-python",
"ale-py==0.7.4",
dfilan marked this conversation as resolved.
Show resolved Hide resolved
"pillow",
"autorom[accept-rom-license]~=0.4.2",
]


setup(
name="seals",
Expand All @@ -73,12 +80,13 @@ def get_readme() -> str:
tests_require=TESTS_REQUIRE,
dfilan marked this conversation as resolved.
Show resolved Hide resolved
extras_require={
# recommended packages for development
"dev": ["ipdb", "jupyter", *TESTS_REQUIRE, *DOCS_REQUIRE],
"dev": ["ipdb", "jupyter", *TESTS_REQUIRE, *DOCS_REQUIRE, *ATARI_REQUIRE],
"docs": DOCS_REQUIRE,
"test": TESTS_REQUIRE,
"test": TESTS_REQUIRE + ATARI_REQUIRE,
# We'd like to specify `gym[mujoco]`, but this is a no-op when Gym is already
# installed. See https://github.com/pypa/pip/issues/4957 for issue.
"mujoco": ["mujoco_py>=1.50, <2.0", "imageio"],
"atari": ATARI_REQUIRE,
},
url="https://github.com/HumanCompatibleAI/benchmark-environments",
license="MIT",
Expand Down
80 changes: 80 additions & 0 deletions src/seals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,83 @@
entry_point=f"seals.mujoco:{env_base}Env",
max_episode_steps=util.get_gym_max_episode_steps(f"{env_base}-v3"),
)

# Atari
dfilan marked this conversation as resolved.
Show resolved Hide resolved

ATARI_ENV_NAMES = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting this into a constant is a good idea, maybe we can do the same for the mujoco environments for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can automate this by something like:

set((env_spec.id.split('-')[0] for env_spec in gym.envs.registry.all() if env_spec.entry_point == 'gym.envs.atari:AtariEnv'))

This won't quite work -- there's some duplicates because of the Deterministic, NoFrameSkip, etc versions but it should be fairly easy to make a variant that handles that.

I'd feel better about interrogating the registry as that's always guaranteed to be up to date, whereas this will gradually drift. Though might want to add a test that asserts this is non-empty (or includes some known-good Atari names), so we'll find out in case the entry point or other detail of gym changes underneath us and breaks this.

"Adventure",
"AirRaid",
"Alien",
"Amidar",
"Assault",
"Asterix",
"Asteroids",
"Atlantis",
"BankHeist",
"BattleZone",
"BeamRider",
"Berzerk",
"Bowling",
"Boxing",
"Breakout",
"Carnival",
"Centipede",
"ChopperCommand",
"CrazyClimber",
"Defender",
"DemonAttack",
"DoubleDunk",
"ElevatorAction",
"Enduro",
"FishingDerby",
"Freeway",
"Frostbite",
"Gopher",
"Gravitar",
"Hero",
"IceHockey",
"Jamesbond",
"JourneyEscape",
"Kangaroo",
"Krull",
"KungFuMaster",
"MontezumaRevenge",
"MsPacman",
"NameThisGame",
"Phoenix",
"Pitfall",
"Pong",
"Pooyan",
"PrivateEye",
"Qbert",
"Riverraid",
"RoadRunner",
"Robotank",
"Seaquest",
"Skiing",
"Solaris",
"SpaceInvaders",
"StarGunner",
"Tennis",
"TimePilot",
"Tutankham",
"UpNDown",
"Venture",
"VideoPinball",
"WizardOfWor",
"YarsRevenge",
"Zaxxon",
]

for env_name in ATARI_ENV_NAMES:
for frameskip in [True, False]:
seals_name = "seals/" + env_name + ("-v5" if frameskip else "NoFrameskip-v4")
func_name = env_name.lower() + ("_v5" if frameskip else "_noframeskip")
gym_name = (
("ALE/" + env_name + "-v5") if frameskip else (env_name + "NoFrameskip-v4")
)
gym.register(
id=seals_name,
entry_point=f"seals.atari:{func_name}",
max_episode_steps=util.get_gym_max_episode_steps(gym_name),
)
Loading