saleml 2 anni fa
parent
commit
fbb8efa6b4

+ 0 - 7
gym_minigrid/envs/fourrooms.py

@@ -66,13 +66,6 @@ class FourRoomsEnv(MiniGridEnv):
             self.place_obj(Goal())
 
         self.mission = "reach the goal"
-<<<<<<< HEAD
-=======
-
-    def step(self, action):
-        obs, reward, done, info = MiniGridEnv.step(self, action)
-        return obs, reward, done, info
->>>>>>> master-upstream
 
 
 register(

+ 2 - 4
gym_minigrid/envs/obstructedmaze.py

@@ -67,8 +67,7 @@ class ObstructedMazeEnv(RoomGrid):
         if blocked:
             vec = DIR_TO_VEC[door_idx]
             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:
             obj = Key(door.color)
@@ -106,8 +105,7 @@ class ObstructedMaze_1Dlhb(ObstructedMazeEnv):
             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)
 
 

+ 8 - 20
gym_minigrid/minigrid.py

@@ -254,12 +254,8 @@ class Door(WorldObj):
             state = 0
         elif self.is_locked:
             state = 2
-<<<<<<< HEAD
-        else:
-=======
         # if door is closed and unlocked
         elif not self.is_open:
->>>>>>> master-upstream
             state = 1
         else:
             raise ValueError(
@@ -336,9 +332,6 @@ class Box(WorldObj):
     def can_pickup(self):
         return True
 
-    def set_contains(self, contains):
-        self.contains = contains
-
     def render(self, img):
         c = COLORS[self.color]
 
@@ -675,7 +668,7 @@ class MiniGridEnv(gym.Env):
         see_through_walls: bool = False,
         agent_view_size: int = 7,
         render_mode: str = None,
-        **kwargs
+        **kwargs,
     ):
         # Can't set both grid_size and width/height
         if grid_size:
@@ -728,18 +721,13 @@ class MiniGridEnv(gym.Env):
         self.see_through_walls = see_through_walls
 
         # Current position and direction of the agent
-<<<<<<< HEAD
-        self.agent_pos = (-1, -1)
-        self.agent_dir = -1
+        self.agent_pos: np.ndarray = None
+        self.agent_dir: int = None
 
         # Current grid and mission and carryinh
         self.grid = Grid(width, height)
         self.mission = ""
         self.carrying = None
-=======
-        self.agent_pos: np.ndarray = None
-        self.agent_dir: int = None
->>>>>>> master-upstream
 
         # Initialize the state
         self.reset()
@@ -755,7 +743,11 @@ class MiniGridEnv(gym.Env):
         self._gen_grid(self.width, self.height)
 
         # These fields should be defined by _gen_grid
-        assert self.agent_pos >= (0, 0) and self.agent_dir >= 0
+        assert (
+            self.agent_pos >= (0, 0)
+            if isinstance(self.agent_pos, tuple)
+            else all(self.agent_pos >= 0) and self.agent_dir >= 0
+        )
 
         # Check that the agent doesn't overlap with an object
         start_cell = self.grid.get(*self.agent_pos)
@@ -1152,12 +1144,8 @@ class MiniGridEnv(gym.Env):
                 terminated = True
                 reward = self._reward()
             if fwd_cell is not None and fwd_cell.type == "lava":
-<<<<<<< HEAD
                 terminated = True
 
-=======
-                done = True
->>>>>>> master-upstream
         # Pick up an object
         elif action == self.actions.pickup:
             if fwd_cell and fwd_cell.can_pickup():

+ 1 - 1
gym_minigrid/roomgrid.py

@@ -205,7 +205,7 @@ class RoomGrid(MiniGridEnv):
             obj = Key(color)
         elif kind == "ball":
             obj = Ball(color)
-        else:  # kind == "box"
+        elif kind == "box":
             obj = Box(color)
         else:
             raise f"{kind} object kind is not available in this environment."