0
$\begingroup$

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!

$\endgroup$

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .