首页 > 其他分享 >OpenAI Gym ProcGen - Getting Action Meanings

OpenAI Gym ProcGen - Getting Action Meanings

时间:2024-09-09 10:23:35浏览次数:13  
标签:Meanings get Gym Getting DOWN procgen env action gym

题意: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

相关文章

  • GYM 105264 E
    题目描述给定一个\(N\)个点的树,你要从中选出一个大小为\(k\)的子树出来,求这个子树的最小直径。思路由于此题允许\(O(N^2)\)的时间复杂度,所以考虑枚举子树的中心。接着以该中心为根向下搜出深度为\(i\)的结点数\(cnt_i\),接着枚举直径长度除\(2\)。由于这里直径可能长......
  • GYM 105264 C
    题目描述给定一个长度为\(N\)的数组\(A\),每次你可以令\(A_i\leftarrowA_i+1\)或\(A_i-1\)。求进行至多\(k\)次操作后\(A\)中最少不同元素数量。思路首先对\(A\)进行排序。令\(dp_{i,j}\)表示考虑前\(i\)个数,有\(j\)个不同的值时最多还能剩余几次操作。很......
  • Why I‘m getting 404 Resource Not Found to my newly Azure OpenAI deployment?
    题意:为什么我新部署的AzureOpenAI服务会出现404资源未找到的错误?问题背景:I'vegonethroughthis quickstart andIcreatedmyAzureOpenAIresource+createdamodeldeploymentwhichisinstatesucceedded.Ialsoplayarounditin AzureOpenAIStudio-Mi......
  • OpenAI Gym custom environment: Discrete observation space with real values
    题意:OpenAIGym自定义环境:具有实数值的离散观测空间问题背景:Iwouldliketocreatecustomopenaigymenvironmentthathasdiscretestatespace,butwithfloatvalues.Tobemoreprecise,itshouldbearangeofvalueswith0.25step:10.0,10.25,10.5,10......
  • Start OpenAI gym on arbitrary initial state
    题意:“在任意初始状态下启动OpenAIGym”问题背景:AnybodyknowsanyOpenAIGymenvironmentswherewecansettheinitialstateofthegame?Forexample,IfoundtheMountainCarContinuous-v0candosuchthingsothatwecanselectatwhichpointthecarst......
  • gym创建环境、自定义gym环境
    环境:half_cheetah.pyfromosimportpathimportnumpyasnpfromgymnasiumimportutilsfromgymnasium.envs.mujocoimportMujocoEnvfromgymnasium.spacesimportBoxDEFAULT_CAMERA_CONFIG={"distance":4.0,}classMOHalfCheetahEnv(Mujoc......
  • gym序列化、EzPickle类
    EzPickle是一个用于强化学习环境的类,它重写了__getstate__和__setstate__方法,以便通过构造函数参数(*args,**kwargs)进行序列化和反序列化。这个设计允许那些无法直接用pickle库处理的对象,如数据库连接和网络套接字,也能在保存和恢复时保持其状态。"""Classforpicklingandun......
  • 3.第一天(第三部分):Getting Started with the IPS Command-Line Interface
    初始化ips清空配置erasecurrent-config擦除配置reset重启默认用户名和密码都是cisco,第一次login的时候提示你修改密码。登录方式sshconnectiontelnet默认不允许cli界面helpconft模式:#conftservicemodeservicehost(配置模式)showsettings查看系统自带配......
  • mujoco gymnasium 环境
    本文简要介绍gynasium中基于mujoco的环境搭建。参照gynasium.envs.mujoco。1.gynasium.Env简介在gynasium中,环境基类为gynasium.Env,其中定义了step,reset,render,close等方法以及action_space,observation_space,reward_range,spec,metadata,np_random......
  • Why unwrap an openAI gym?
    题意:为什么要“解开”OpenAIGym?问题背景:I'mtryingtogetsomeinsightsintoreinforcementlearningwhileusingopenAIgymasalearningenvironment.Idothisbyreadingthebook Hands-onreinforcementlearningwithPython.Inthisbook,somecodeisp......