AttributeError: 'Timer' object has no attribute '_seed'

匿名 (未验证) 提交于 2019-12-03 01:40:02

问题:

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' 

回答1:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!