from gym_minigrid.minigrid import * from gym_minigrid.register import register class EmptyEnv(MiniGridEnv): """ Empty grid environment, no obstacles, sparse reward """ def __init__(self, size=8): super().__init__(gridSize=size, maxSteps=3*size) def _genGrid(self, width, height): # Create an empty grid self.grid = Grid(width, height) # Generate the surrounding walls self.grid.horzWall(0, 0) self.grid.horzWall(0, height-1) self.grid.vertWall(0, 0) self.grid.vertWall(width-1, 0) # Place a goal square in the bottom-right corner self.grid.set(width - 2, height - 2, Goal()) self.mission = "get to the green goal square" class EmptyEnv6x6(EmptyEnv): def __init__(self): super().__init__(size=6) class EmptyEnv16x16(EmptyEnv): def __init__(self): super().__init__(size=16) register( id='MiniGrid-Empty-6x6-v0', entry_point='gym_minigrid.envs:EmptyEnv6x6' ) register( id='MiniGrid-Empty-8x8-v0', entry_point='gym_minigrid.envs:EmptyEnv' ) register( id='MiniGrid-Empty-16x16-v0', entry_point='gym_minigrid.envs:EmptyEnv16x16' )