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