Adding new environment


#1

I want to create my own environment. I followed every step on this web https://github.com/openai/gym/tree/master/gym/envs. But when i tried to run it. I got the error message:

Traceback (most recent call last):
File “CartPole.py”, line 2, in
import gym
File “/Users/dxzhu/Documents/Gitedepo/gym/gym/init.py”, line 53, in
from gym.scoreboard.api import upload
File “/Users/dxzhu/Documents/Gitedepo/gym/gym/scoreboard/init.py”, line 195, in
contributor=‘mygithubhandle’,
File “/Users/dxzhu/Documents/Gitedepo/gym/gym/scoreboard/registration.py”, line 40, in add_task
self.groups[group][‘envs’].append(id)
KeyError: ‘my_collection’

Can anyone help me with that?


#2

Hi,

I’m experiencing the same issue. Did you solve it since then?

Thanks in advance,
Alena


#3

I am experiencing the same issue too. Anybody have pointers?


#4

Here’s the preferred way to create one’s own environment:

  1. Create the file structure (somewhere outside of gym) as mentioned on the page referenced by zdx66536, under How to create new environments for Gym.

  2. The instructions forget to fill in gym-foo/gym_foo/envs/foo_extrahard_env.py. Make it look the same as foo_env.py, except change the class name to FooExtraHardEnv.

  3. cd into gym-foo and run:

    pip install -e .
    
  4. Modify foo_env.py to make it behave as you wish.

  5. Then use it as follows:

    import gym
    import gym_foo
    env = gym.make('foo-v0')
    

Please let me know if something goes wrong.