AttributeError:“计时器”对象没有属性“ _seed”

时间:2018-08-09 06:30:29

标签: python-3.x docker openai-gym

这是我使用的代码。我在https://github.com/openai/universe#breaking-down-the-example上找到了此代码。由于我在远程管理器上遇到错误,因此我必须复制此代码以运行它。但这仍然给我以下错误

import gym
import universe  # register the universe environments

    env = gym.make('flashgames.DuskDrive-v0')
    env.configure(remotes=1)  # automatically creates a local docker container
    observation_n = env.reset()

    while True:
      action_n = [[('KeyEvent', 'ArrowUp', True)] for ob in observation_n]  # your agent here
      observation_n, reward_n, done_n, info = env.step(action_n)
      env.render()

尝试在上述脚本上运行时得到此提示。我尝试了所有可能的方法来解决它,但仍然会导致相同的错误。甚至没有一个线程。我现在不知道该怎么办,请告诉我是否有人解决了这个问题。

我在Windows 10上运行的虚拟机上使用Ubuntu 18.04 LTS

    WARN: Environment '<class 'universe.wrappers.timer.Timer'>' has deprecated methods '_step' and '_reset' rather than 'step' and 'reset'. Compatibility code invoked. Set _gym_disable_underscore_compat = True to disable this behavior.
Traceback (most recent call last):
  File "gymtest1.py", line 4, in <module>
    env = gym.make("flashgames.CoasterRacer-v0")
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 167, in make
    return registry.make(id)
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 125, in make
    patch_deprecated_methods(env)
  File "/home/mystery/.local/lib/python3.6/site-packages/gym/envs/registration.py", line 185, in patch_deprecated_methods
    env.seed  = env._seed
AttributeError: 'Timer' object has no attribute '_seed'

1 个答案:

答案 0 :(得分:0)

因此,我认为您需要在Timer module中添加几行,因为代码检查代码是否实现了某些功能(_step,_reset,_seed等)

所以(我认为)您需要做的就是在Timer类的末尾添加:

def _seed(self, seed_num=0): # this is so that you can get consistent results
    pass                     # optionally, you could add: random.seed(random_num)
    return