Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

python 3.x - AttributeError: 'Timer' object has no attribute '_seed'

This is the code I used. I found this code on https://github.com/openai/universe#breaking-down-the-example . As I'm getting error on remote manager so I have to copy this code to run it. But it still giving me error as below

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()

I'm getting this when try to run above script. I tried every possible way to solve it, but it still causing the same error. There is not even one thread about this. I don't know what to do now please tell me if anyone of you solved it.

I'm using Ubuntu 18.04 LTS on virtual box which is running on Windows 10

    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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

So I think what you need to do add a few lines in the Timer module because the code checks whether the code implements certain functions (_step, _reset, _seed, etc...)

So all you need to do (I think) is add at the end of the Timer class:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...