浏览代码

pre-commit now works

saleml 2 年之前
父节点
当前提交
602010892b
共有 2 个文件被更改,包括 11 次插入13 次删除
  1. 2 4
      gym_minigrid/envs/obstructedmaze.py
  2. 9 9
      gym_minigrid/wrappers.py

+ 2 - 4
gym_minigrid/envs/obstructedmaze.py

@@ -67,8 +67,7 @@ class ObstructedMazeEnv(RoomGrid):
         if blocked:
         if blocked:
             vec = DIR_TO_VEC[door_idx]
             vec = DIR_TO_VEC[door_idx]
             blocking_ball = Ball(self.blocking_ball_color) if blocked else None
             blocking_ball = Ball(self.blocking_ball_color) if blocked else None
-            self.grid.set(door_pos[0] - vec[0],
-                          door_pos[1] - vec[1], blocking_ball)
+            self.grid.set(door_pos[0] - vec[0], door_pos[1] - vec[1], blocking_ball)
 
 
         if locked:
         if locked:
             obj = Key(door.color)
             obj = Key(door.color)
@@ -106,8 +105,7 @@ class ObstructedMaze_1Dlhb(ObstructedMazeEnv):
             blocked=self.blocked,
             blocked=self.blocked,
         )
         )
 
 
-        self.obj, _ = self.add_object(
-            1, 0, "ball", color=self.ball_to_find_color)
+        self.obj, _ = self.add_object(1, 0, "ball", color=self.ball_to_find_color)
         self.place_agent(0, 0)
         self.place_agent(0, 0)
 
 
 
 

+ 9 - 9
gym_minigrid/wrappers.py

@@ -98,7 +98,7 @@ class StateBonus(gym.Wrapper):
         return self.env.reset(**kwargs)
         return self.env.reset(**kwargs)
 
 
 
 
-class ImgObsWrapper(gym.ObservationWrapper):
+class ImgObsWrapper(gym.Wrapper):
     """
     """
     Use the image as the only observation output, no language/mission.
     Use the image as the only observation output, no language/mission.
     """
     """
@@ -111,7 +111,7 @@ class ImgObsWrapper(gym.ObservationWrapper):
         return obs["image"]
         return obs["image"]
 
 
 
 
-class OneHotPartialObsWrapper(gym.ObservationWrapper):
+class OneHotPartialObsWrapper(gym.Wrapper):
     """
     """
     Wrapper to get a one-hot encoding of a partially observable
     Wrapper to get a one-hot encoding of a partially observable
     agent view as observation.
     agent view as observation.
@@ -151,7 +151,7 @@ class OneHotPartialObsWrapper(gym.ObservationWrapper):
         return {**obs, "image": out}
         return {**obs, "image": out}
 
 
 
 
-class RGBImgObsWrapper(gym.ObservationWrapper):
+class RGBImgObsWrapper(gym.Wrapper):
     """
     """
     Wrapper to use fully observable RGB image as observation,
     Wrapper to use fully observable RGB image as observation,
     This can be used to have the agent to solve the gridworld in pixel space.
     This can be used to have the agent to solve the gridworld in pixel space.
@@ -183,7 +183,7 @@ class RGBImgObsWrapper(gym.ObservationWrapper):
         return {**obs, "image": rgb_img}
         return {**obs, "image": rgb_img}
 
 
 
 
-class RGBImgPartialObsWrapper(gym.ObservationWrapper):
+class RGBImgPartialObsWrapper(gym.Wrapper):
     """
     """
     Wrapper to use partially observable RGB image as observation.
     Wrapper to use partially observable RGB image as observation.
     This can be used to have the agent to solve the gridworld in pixel space.
     This can be used to have the agent to solve the gridworld in pixel space.
@@ -214,7 +214,7 @@ class RGBImgPartialObsWrapper(gym.ObservationWrapper):
         return {**obs, "image": rgb_img_partial}
         return {**obs, "image": rgb_img_partial}
 
 
 
 
-class FullyObsWrapper(gym.ObservationWrapper):
+class FullyObsWrapper(gym.Wrapper):
     """
     """
     Fully observable gridworld using a compact grid encoding
     Fully observable gridworld using a compact grid encoding
     """
     """
@@ -243,7 +243,7 @@ class FullyObsWrapper(gym.ObservationWrapper):
         return {**obs, "image": full_grid}
         return {**obs, "image": full_grid}
 
 
 
 
-class DictObservationSpaceWrapper(gym.ObservationWrapper):
+class DictObservationSpaceWrapper(gym.Wrapper):
     """
     """
     Transforms the observation space (that has a textual component) to a fully numerical observation space,
     Transforms the observation space (that has a textual component) to a fully numerical observation space,
     where the textual instructions are replaced by arrays representing the indices of each word in a fixed vocabulary.
     where the textual instructions are replaced by arrays representing the indices of each word in a fixed vocabulary.
@@ -361,7 +361,7 @@ class DictObservationSpaceWrapper(gym.ObservationWrapper):
         return obs
         return obs
 
 
 
 
-class FlatObsWrapper(gym.ObservationWrapper):
+class FlatObsWrapper(gym.Wrapper):
     """
     """
     Encode mission strings using a one-hot scheme,
     Encode mission strings using a one-hot scheme,
     and combine these with observed images into one flat array
     and combine these with observed images into one flat array
@@ -455,7 +455,7 @@ class ViewSizeWrapper(gym.Wrapper):
         return {**obs, "image": image}
         return {**obs, "image": image}
 
 
 
 
-class DirectionObsWrapper(gym.ObservationWrapper):
+class DirectionObsWrapper(gym.Wrapper):
     """
     """
     Provides the slope/angular direction to the goal with the observations as modeled by (y2 - y2 )/( x2 - x1)
     Provides the slope/angular direction to the goal with the observations as modeled by (y2 - y2 )/( x2 - x1)
     type = {slope , angle}
     type = {slope , angle}
@@ -489,7 +489,7 @@ class DirectionObsWrapper(gym.ObservationWrapper):
         return obs
         return obs
 
 
 
 
-class SymbolicObsWrapper(gym.ObservationWrapper):
+class SymbolicObsWrapper(gym.Wrapper):
     """
     """
     Fully observable grid with a symbolic state representation.
     Fully observable grid with a symbolic state representation.
     The symbol is a triple of (X, Y, IDX), where X and Y are
     The symbol is a triple of (X, Y, IDX), where X and Y are