Skip to content

Commit

Permalink
Updated for Gymnasium API
Browse files Browse the repository at this point in the history
  • Loading branch information
simondlevy committed Sep 10, 2023
1 parent 4a08d19 commit 0e95ecd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 11 additions & 3 deletions gym_mygame/envs/mygame.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self):

def step(self, action):

state = [0]
state = np.zeros(1, dtype=np.float32)
reward = 0
terminated = False
truncated = False
Expand All @@ -36,9 +36,17 @@ def render(self, mode='human'):

pass

def reset(self):
def reset(self, seed=None, options={}):

return [0]
if seed is not None:

pass # XXX Seed the random-number generator

obs = np.zeros(1, dtype=np.float32)

info = {}

return obs, info

def close(self):

Expand Down
4 changes: 1 addition & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

for i_episode in range(20):

observation = env.reset()
observation, _ = env.reset(seed=123)

for t in range(100):

env.render()

print(observation)

action = env.action_space.sample()

observation, reward, terminated, truncated, info = env.step(action)
Expand Down

0 comments on commit 0e95ecd

Please sign in to comment.