Following this (unreadable) forum post, I thought it was fitting to post it up on stack overflow for future generations who search for it.
How to pass arguments for gym environments on init?
Citation in Harvard styleBrockman, G. et al., 2016. Openai gym. arXiv preprint arXiv:1606.01540.
The observation_space defines the structure as well as the legitimate values for the observation of the state of the environment. The observation can be different things for different environments.
Even though it can be installed on Windows using Conda or PIP, it cannot be visualized on Windows. If you run it on a headless server (such as a virtual machine on the cloud), then it needs PyVirtualDisplay, which doesn't work on Windows either. Therefore, playing the OpenAI Gym on Windows is inconvenient.
In the meantime the support for arguments in gym.make
has been implemented, so you can pass key word arguments to make
right after environment name:
your_env = gym.make('YourEnv', some_kwarg=your_vars)
The gym
version that I'm running is 0.12.4
.
UPDATE: This is supported from version 0.10.10.
. Reference. Thanks @Wojciech.
Method 1 - Use the built in register
functionality:
Re-register the environment with a new name
For example:
'Blackjack-natural-v0'
Instead of the original
'Blackjack-v0'
First you need to import the register function:
from gym.envs.registration import register
Then you use the register function like this:
register( id='Blackjack-natural-v0', entry_point='gym.envs.toy_text:BlackjackEnv', kwargs={'natural': True} )
Method 2 - Add an extra method to your env:
If you can just call another init method after gym.make, then you can just do:
your_env = gym.make("YourEnv")
your_env.env.your_init(your_vars)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With