题意:OpenAI Gym ProcGen - 获取动作含义
问题背景:
In the OpenAI ProcGen gym, I am not getting a way to get the meanings of the action values, I can see that there are 15 actions for the coinrun environment using env.action_space.n
. I have tried both the Gym and the Gym3 versions.
在 OpenAI ProcGen gym 中,我无法找到获取动作值含义的方法。我可以看到使用 env.action_space.n
在 coinrun 环境中存在 15 个动作。我已经尝试过 Gym 和 Gym3 两个版本。
This is how I make the environment (gym version).
这是我如何创建环境(gym 版本)的。
env = gym.make('procgen:procgen-%s-v0'%('coinrun'))
Neither of these are working to seem to work.
这两个似乎都不起作用。
env.action_spec()
env.env.get_action_meanings()
I have tried to change env
with env.env
and env.env.env
, nothing works. I get the message: AttributeError: 'ToGymEnv' object has no attribute 'get_action_meanings'
.
我尝试用 env.env
和 env.env.env
来替换 env
,但都没有成功。我收到了这样的错误消息:AttributeError: 'ToGymEnv' object has no attribute 'get_action_meanings'
。
Please tell me how I can get the labelled action list.
请告诉我怎样获取带标签的动作列表
Object Types: env
is a ToGymEnv
object, env.env
is , and env.env.env
is ProcgenGym3Env
.
对象类型:env
是一个 ToGymEnv
对象,env.env
的类型未明确给出,而 env.env.env
是一个 ProcgenGym3Env
对象。
问题解决:
The action meanings are hidden in the get_combos
method in the procgen.env
.
动作的含义隐藏在 procgen.env
中的 get_combos
方法里
def get_combos(self):
return [
("LEFT", "DOWN"),
("LEFT",),
("LEFT", "UP"),
("DOWN",),
(),
("UP",),
("RIGHT", "DOWN"),
("RIGHT",),
("RIGHT", "UP"),
("D",),
("A",),
("W",),
("S",),
("Q",),
("E",),
]
To access them from an environment created in gym (procgen==0.10.4
) you can use:
在通过 gym 创建的环境(procgen 版本为 0.10.4)中访问它们,你可以使用:
env = gym.make('procgen:procgen-%s-v0'%('coinrun'))
print(env.unwrapped.env.env.combos)
Which will result in:
这将导致:
[('LEFT', 'DOWN'), ('LEFT',), ('LEFT', 'UP'), ('DOWN',), (), ('UP',), ('RIGHT', 'DOWN'), ('RIGHT',), ('RIGHT', 'UP'), ('D',), ('A',), ('W',), ('S',), ('Q',), ('E',)]
In order to acces them from a ProcgenEnv
use:
为了从 ProcgenEnv
访问它们,请使用:
env = procgen.ProcgenEnv(env_name='maze', num_envs=1)
print(env.env.combos)
标签:Meanings,get,Gym,Getting,DOWN,procgen,env,action,gym
From: https://blog.csdn.net/suiusoar/article/details/142050037