<p>There is a typo in</p>
<pre><code>class SliceEnv(gym.Env, **braid):
    def __init__(self, **braid):
</code></pre>
<p>Instead it should be</p>
<pre><code>
class SliceEnv(gym.Env):
    def __init__(self, **braid):
</code></pre>
<p>Are you sure you need kwarg? Why not normal arguments? Also here is an <a href="https://realpython.com/python-kwargs-and-args/" rel="nofollow noreferrer">article</a> that explains <code>kwarg</code>.</p>

CC BY-SA 4.0
2023-08-15T15:46:16.920Z
2023-08-15T15:46:16.920Z
penkovsky
<p>I have a custom gym (not gymnasium) environment that I am using for research. I am currently using gym version 0.19.0 installed using conda-forge. Glossing over a lot of details, the agent is learning to untangle mathematical knots. With the environment, I have to set the knot to use before I use the environment. Here is what it looks like:</p>
<pre><code>class SliceEnv(gym.Env):
    def __init__(self):
        self.MP_knots={
        '4_1': [3, [1, -2, 1, -2]],
        '7_1': [2, [1 ,1, 1, 1, 1, 1, 1]],
         ...
        }
    ...
        self.starting_braid = '4_1'
</code></pre>
<p>I am trying to set up my environment to where I can pick which knot I want to use while training (so if the agent figures out knot 4_1 several times in a row, it can move onto the 7_1 knot). I tried:</p>
<pre><code>class SliceEnv(gym.Env, **braid):
    def __init__(self, **braid):
        self.MP_knots={
        '4_1': [3, [1, -2, 1, -2]],
        '7_1': [2, [1 ,1, 1, 1, 1, 1, 1]],
         ...
        }
    ...
        self.starting_braid = braid
</code></pre>
<p>where <code>braid</code> is something I pass into the environment while training, but I got the error <code>NameError: name 'braid' is not defined</code>. I'm probably using **kwargs wrong.</p>
<p>Any ideas on how to solve this? Is there a better way than the way I am proposing?</p>
<p>Thank you!</p>

<deep-rl><gym>
Can I add additional arguments to my custom Gym Environment?
user20057611
# Can I add additional arguments to my custom Gym Environment?

(Asked by: username_0 on 2023-08-15)

I have a custom gym (not gymnasium) environment that I am using for research. I am currently using gym version 0.19.0 installed using conda-forge. Glossing over a lot of details, the agent is learning to untangle mathematical knots. With the environment, I have to set the knot to use before I use the environment. Here is what it looks like:
class SliceEnv(gym.Env):
    def __init__(self):
        self.MP_knots={
        '4_1': [3, [1, -2, 1, -2]],
        '7_1': [2, [1 ,1, 1, 1, 1, 1, 1]],
         ...
        }
    ...
        self.starting_braid = '4_1'

I am trying to set up my environment to where I can pick which knot I want to use while training (so if the agent figures out knot 4_1 several times in a row, it can move onto the 7_1 knot). I tried:
class SliceEnv(gym.Env, **braid):
    def __init__(self, **braid):
        self.MP_knots={
        '4_1': [3, [1, -2, 1, -2]],
        '7_1': [2, [1 ,1, 1, 1, 1, 1, 1]],
         ...
        }
    ...
        self.starting_braid = braid

where braid is something I pass into the environment while training, but I got the error NameError: name 'braid' is not defined. I'm probably using **kwargs wrong.
Any ideas on how to solve this? Is there a better way than the way I am proposing?
Thank you!

**Tags:** deep-rl, gym


---

## 1 answers

### Answer by username_1 on 2023-08-15. Score: 1

There is a typo in
class SliceEnv(gym.Env, **braid):
    def __init__(self, **braid):

Instead it should be

class SliceEnv(gym.Env):
    def __init__(self, **braid):

Are you sure you need kwarg? Why not normal arguments? Also here is an article that explains kwarg.


---

