List all environment id in openai gym

Zuoanqh picture Zuoanqh · Feb 26, 2018 · Viewed 7k times · Source

How to list all currently registered environment IDs (as they are used for creating environments) in openai gym?

A bit context: there are many plugins installed which have customary ids such as atari, super mario, doom etc.

Not to be confused with game names for atari-py.

Answer

Dennis Soemers picture Dennis Soemers · Feb 26, 2018

Use envs.registry.all():

from gym import envs
print(envs.registry.all())

Out:

dict_values([EnvSpec(Copy-v0), EnvSpec(RepeatCopy-v0), EnvSpec(ReversedAddition-v0), EnvSpec(ReversedAddition3-v0), EnvSpec(DuplicatedInput-v0), EnvSpec(Reverse-v0), EnvSpec(CartPole-v0), ...])

This returns a large collection of EnvSpec objects, not specifically of the IDs as you asked. You can get those like this:

from gym import envs
all_envs = envs.registry.all()
env_ids = [env_spec.id for env_spec in all_envs]
print(env_ids)

Out:

['Copy-v0', 'RepeatCopy-v0', 'ReversedAddition-v0', 'ReversedAddition3-v0', 'DuplicatedInput-v0', 'Reverse-v0', 'CartPole-v0', ...]