题意:“在任意初始状态下启动 OpenAI Gym”
问题背景:
Anybody knows any OpenAI Gym environments where we can set the initial state of the game? For example, I found the MountainCarContinuous-v0 can do such thing so that we can select at which point the car starts. However, I am looking for another more complex environment. Thanks in advance for your help!
“有人知道可以设置游戏初始状态的 OpenAI Gym 环境吗?例如,我发现 MountainCarContinuous-v0 可以做到这一点,这样我们可以选择汽车从哪个点开始。但是,我正在寻找另一个更复杂的环境。提前感谢您的帮助!”
问题解决:
You have to redefine the reset
function of the class (for example, this). You may want to define it such that it gets as input your desired state, something like
“你需要重新定义这个类的 reset
函数(例如,this)。你可能希望将其定义为接受你所需状态作为输入的形式,类似于这样”
def reset(self, state):
self.state = state
return np.array(self.state)
This should work for all OpenAI gym environments. If you want to do it for other simulators, things may be different. For instance, MuJoCo allows to do something like
“这应该适用于所有 OpenAI Gym 环境。如果你想在其他模拟器中实现这一点,情况可能会有所不同。例如,MuJoCo 允许你做类似的事情。”
saved_state = env.sim.get_state()
env.sim.set_state(saved_state)
标签:reset,do,Gym,initial,self,Start,state,OpenAI,gym
From: https://blog.csdn.net/suiusoar/article/details/141601045