List all environment id in openai gym
Use envs.registry.all()
:
from gym import envsprint(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 envsall_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', ...]
You can use this code for listing all environments in gym:
import gymfor i in gym.envs.registry.all(): print(i.id)