利用健身房训练机器人

2024-04-18 11:51:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用这本书

Training of robots using gym

在这本书中,有一个'BipedalWalker-v2'的例子,为此我使用了这本书中的代码

import gym
env = gym.make('BipedalWalker-v2')
for i_episode in range(100):
 observation = env.reset()
 for t in range(10000):
     env.render()
     print(observation)
     action = env.action_space.sample()
     observation, reward, done, info = env.step(action)
     if done:
         print("{} timesteps taken for the episode".format(t+1))
         break

但当我运行代码时,它会给我这样的错误

I:\scientific_python\Scripts\python.exe I:/scientific_python/python_important_functions/Reinforcement_learning_python.py
Traceback (most recent call last):
  File "I:/scientific_python/python_important_functions/Reinforcement_learning_python.py", line 2, in <module>
    env = gym.make('BipedalWalker-v2')
  File "C:\Users\Dato\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 156, in make
    return registry.make(id, **kwargs)
  File "C:\Users\Dato\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 101, in make
    env = spec.make(**kwargs)
  File "C:\Users\Dato\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 72, in make
    cls = load(self.entry_point)
  File "C:\Users\Dato\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 18, in load
    fn = getattr(mod, attr_name)
AttributeError: module 'gym.envs.box2d' has no attribute 'BipedalWalker'

所以这个属性可能在不同的工具下,对吧?你能帮我解决这样的任务吗?你知道吗


Tags: inpyenvmakelocallineusersappdata