使用健身房行走的机器人训练

时间:2019-08-11 11:42:10

标签: python openai-gym

我正在使用这本书

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'

所以这个属性可能在不同的工具下正确吗?你能帮我解决这个任务吗?

1 个答案:

答案 0 :(得分:0)

在pip install中构建Box2D所需的conda install swig#

pip install box2d-py#pybox2d的重新打包版本