简体   繁体   English

列出openai Gym中的所有环境id

[英]List all environment id in openai gym

How to list all currently registered environment IDs (as they are used for creating environments) in openai gym?如何在 openai Gym 中列出所有当前注册的环境 ID(因为它们用于创建环境)?

A bit context: there are many plugins installed which have customary ids such as atari, super mario, doom etc.一点背景:安装了许多具有惯用 ID 的插件,例如 atari、super mario、doom 等。

Not to be confused with game names for atari-py.不要与 atari-py 的游戏名称混淆。

Use envs.registry.all() : 使用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), ...]) 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. 这会返回大量EnvSpec对象,而不是您提出的ID。 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', ...] ['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 gym
for i in gym.envs.registry.all():
  print(i.id)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM