class MazeEnv(gym.Env): metadata = {'render.modes': ['human']} id = "maze-v0" def __init__(self, width, height, mechanic, mechanic_args): self.env = MazeGame((width, height), mechanic=mechanic, mechanic_args=mechanic_args) self.observation_space = self.env.get_state().shape self.action_space = 4 def step(self, action, type): return self.env.step(action, type) def reset(self): return self.env.reset() def render(self, mode=0, close=False): if close: self.env.quit() return None return self.env.render(type=mode)
class MazeEnv(gym.Env): metadata = {'render.modes': ['human']} id = "maze-v0" def __init__(self, width, height, state_type, mechanic, mechanic_args): self.env = MazeGame((width, height), mechanic=mechanic, mechanic_args=mechanic_args) if state_type == "image": self.env.set_preprocess(dict( image=dict(), #resize=dict(size=(84, 84)), #grayscale=dict() )) self.observation_space = self.env.get_state().shape self.action_space = 4 def step(self, action): return self.env.step(action) def reset(self): return self.env.reset() def render(self, mode='human', close=False): if close: self.env.quit() return None return self.env.render()
class NoMazeEnv(gym.Env): metadata = {'render.modes': ['human']} id = "NoMaze-%s-%sx%s-v0" class NoMazeMechanic(BaseMazeMechanic): def on_start(self): pass def on_update(self): pass def on_terminal(self): pass def __init__(self, width, height, state_type): opt = dict(algorithm="none", disable_target=True) self.env = MazeGame((width, height), mechanic=NoMazeEnv.NoMazeMechanic, mechanic_args=None, options=opt) if state_type == "image": self.env.set_preprocess( dict(image=dict(), #resize=dict(size=(84, 84)), #grayscale=dict() )) self.observation_space = self.env.get_state().shape self.action_space = 4 def step(self, action): return self.env.step(action) def reset(self): return self.env.reset() def render(self, mode='human', close=False): if close: self.env.quit() return None return self.env.render()
class NoMazeEnv(gym.Env): metadata = {'render.modes': ['human']} id = "NoMaze-%s-%sx%s-v0" class NoMazeMechanic(BaseMazeMechanic): def on_start(self): pass def on_update(self): pass def on_terminal(self): pass def __init__(self, width, height): opt = dict(algorithm="none", disable_target=True) self.env = MazeGame((width, height), mechanic=NoMazeEnv.NoMazeMechanic, mechanic_args=None, options=opt) self.observation_space = self.env.get_state().shape self.action_space = 4 def step(self, action, type): return self.env.step(action, type) def reset(self): return self.env.reset() def render(self, mode=0, close=False): if close: self.env.quit() return None return self.env.render(type=mode)