Przeglądaj źródła

Finished renaming MiniGrid methods for PEP8 conformance

Maxime Chevalier-Boisvert 7 lat temu
rodzic
commit
852476db7c

+ 7 - 10
gym_minigrid/envs/doorkey.py

@@ -14,28 +14,25 @@ class DoorKeyEnv(MiniGridEnv):
         self.grid = Grid(width, height)
 
         # Generate the surrounding walls
-        self.grid.wallRect(0, 0, width, height)
+        self.grid.wall_rect(0, 0, width, height)
 
         # Place a goal in the bottom-right corner
         self.grid.set(width - 2, height - 2, Goal())
 
         # Create a vertical splitting wall
-        splitIdx = self._randInt(2, width-2)
-        self.grid.vertWall(splitIdx, 0)
+        splitIdx = self._rand_int(2, width-2)
+        self.grid.vert_wall(splitIdx, 0)
 
         # Place the agent at a random position and orientation
-        self.start_pos = self._randPos(
-            1, splitIdx,
-            1, height-1
-        )
-        self.start_dir = self._randInt(0, 4)
+        # on the left side of the splitting wall
+        self.start_pos = self.place_agent(size=(splitIdx, height))
 
         # Place a door in the wall
-        doorIdx = self._randInt(1, width-2)
+        doorIdx = self._rand_int(1, width-2)
         self.grid.set(splitIdx, doorIdx, LockedDoor('yellow'))
 
         # Place a yellow key on the left side
-        self.placeObj(
+        self.place_obj(
             obj=Key('yellow'),
             top=(0, 0),
             size=(splitIdx, height)

+ 1 - 1
gym_minigrid/envs/empty.py

@@ -19,7 +19,7 @@ class EmptyEnv(MiniGridEnv):
         self.grid = Grid(width, height)
 
         # Generate the surrounding walls
-        self.grid.wallRect(0, 0, width, height)
+        self.grid.wall_rect(0, 0, width, height)
 
         # Place the agent in the top-left corner
         self.start_pos = (1, 1)

+ 10 - 10
gym_minigrid/envs/fetch.py

@@ -27,10 +27,10 @@ class FetchEnv(MiniGridEnv):
         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)
+        self.grid.horz_wall(0, 0)
+        self.grid.horz_wall(0, height-1)
+        self.grid.vert_wall(0, 0)
+        self.grid.vert_wall(width-1, 0)
 
         types = ['key', 'ball']
 
@@ -38,29 +38,29 @@ class FetchEnv(MiniGridEnv):
 
         # For each object to be generated
         while len(objs) < self.numObjs:
-            objType = self._randElem(types)
-            objColor = self._randElem(COLOR_NAMES)
+            objType = self._rand_elem(types)
+            objColor = self._rand_elem(COLOR_NAMES)
 
             if objType == 'key':
                 obj = Key(objColor)
             elif objType == 'ball':
                 obj = Ball(objColor)
 
-            self.placeObj(obj)
+            self.place_obj(obj)
             objs.append(obj)
 
         # Randomize the player start position and orientation
-        self.placeAgent()
+        self.place_agent()
 
         # Choose a random object to be picked up
-        target = objs[self._randInt(0, len(objs))]
+        target = objs[self._rand_int(0, len(objs))]
         self.targetType = target.type
         self.targetColor = target.color
 
         descStr = '%s %s' % (self.targetColor, self.targetType)
 
         # Generate the mission string
-        idx = self._randInt(0, 5)
+        idx = self._rand_int(0, 5)
         if idx == 0:
             self.mission = 'get a %s' % descStr
         elif idx == 1:

+ 10 - 10
gym_minigrid/envs/gotodoor.py

@@ -27,23 +27,23 @@ class GoToDoorEnv(MiniGridEnv):
         self.grid = Grid(width, height)
 
         # Randomly vary the room width and height
-        width = self._randInt(5, width+1)
-        height = self._randInt(5, height+1)
+        width = self._rand_int(5, width+1)
+        height = self._rand_int(5, height+1)
 
         # Generate the surrounding walls
-        self.grid.wallRect(0, 0, width, height)
+        self.grid.wall_rect(0, 0, width, height)
 
         # Generate the 4 doors at random positions
         doorPos = []
-        doorPos.append((self._randInt(2, width-2), 0))
-        doorPos.append((self._randInt(2, width-2), height-1))
-        doorPos.append((0, self._randInt(2, height-2)))
-        doorPos.append((width-1, self._randInt(2, height-2)))
+        doorPos.append((self._rand_int(2, width-2), 0))
+        doorPos.append((self._rand_int(2, width-2), height-1))
+        doorPos.append((0, self._rand_int(2, height-2)))
+        doorPos.append((width-1, self._rand_int(2, height-2)))
 
         # Generate the door colors
         doorColors = []
         while len(doorColors) < len(doorPos):
-            color = self._randElem(COLOR_NAMES)
+            color = self._rand_elem(COLOR_NAMES)
             if color in doorColors:
                 continue
             doorColors.append(color)
@@ -54,10 +54,10 @@ class GoToDoorEnv(MiniGridEnv):
             self.grid.set(*pos, Door(color))
 
         # Randomize the agent start position and orientation
-        self.placeAgent(size=(width, height))
+        self.place_agent(size=(width, height))
 
         # Select a random target door
-        doorIdx = self._randInt(0, len(doorPos))
+        doorIdx = self._rand_int(0, len(doorPos))
         self.target_pos = doorPos[doorIdx]
         self.target_color = doorColors[doorIdx]
 

+ 6 - 6
gym_minigrid/envs/gotoobject.py

@@ -27,7 +27,7 @@ class GoToObjectEnv(MiniGridEnv):
         self.grid = Grid(width, height)
 
         # Generate the surrounding walls
-        self.grid.wallRect(0, 0, width, height)
+        self.grid.wall_rect(0, 0, width, height)
 
         # Types and colors of objects we can generate
         types = ['key', 'ball', 'box']
@@ -37,8 +37,8 @@ class GoToObjectEnv(MiniGridEnv):
 
         # Until we have generated all the objects
         while len(objs) < self.numObjs:
-            objType = self._randElem(types)
-            objColor = self._randElem(COLOR_NAMES)
+            objType = self._rand_elem(types)
+            objColor = self._rand_elem(COLOR_NAMES)
 
             # If this object already exists, try again
             if (objType, objColor) in objs:
@@ -51,15 +51,15 @@ class GoToObjectEnv(MiniGridEnv):
             elif objType == 'box':
                 obj = Box(objColor)
 
-            pos = self.placeObj(obj)
+            pos = self.place_obj(obj)
             objs.append((objType, objColor))
             objPos.append(pos)
 
         # Randomize the agent start position and orientation
-        self.placeAgent()
+        self.place_agent()
 
         # Choose a random object to be picked up
-        objIdx = self._randInt(0, len(objs))
+        objIdx = self._rand_int(0, len(objs))
         self.targetType, self.target_color = objs[objIdx]
         self.target_pos = objPos[objIdx]
 

+ 10 - 11
gym_minigrid/envs/lockedroom.py

@@ -14,10 +14,10 @@ class Room:
         self.color = None
         self.locked = False
 
-    def randPos(self, env):
+    def rand_pos(self, env):
         topX, topY = self.top
         sizeX, sizeY = self.size
-        return env._randPos(
+        return env._rand_pos(
             topX + 1, topX + sizeX - 1,
             topY + 1, topY + sizeY - 1
         )
@@ -81,15 +81,15 @@ class LockedRoom(MiniGridEnv):
             ))
 
         # Choose one random room to be locked
-        lockedRoom = self._randElem(self.rooms)
+        lockedRoom = self._rand_elem(self.rooms)
         lockedRoom.locked = True
-        goalPos = lockedRoom.randPos(self)
+        goalPos = lockedRoom.rand_pos(self)
         self.grid.set(*goalPos, Goal())
 
         # Assign the door colors
         colors = set(COLOR_NAMES)
         for room in self.rooms:
-            color = self._randElem(sorted(colors))
+            color = self._rand_elem(sorted(colors))
             colors.remove(color)
             room.color = color
             if room.locked:
@@ -99,18 +99,17 @@ class LockedRoom(MiniGridEnv):
 
         # Select a random room to contain the key
         while True:
-            keyRoom = self._randElem(self.rooms)
+            keyRoom = self._rand_elem(self.rooms)
             if keyRoom != lockedRoom:
                 break
-        keyPos = keyRoom.randPos(self)
+        keyPos = keyRoom.rand_pos(self)
         self.grid.set(*keyPos, Key(lockedRoom.color))
 
         # Randomize the player start position and orientation
-        self.start_pos = self._randPos(
-            lWallIdx + 1, rWallIdx,
-            1, height-1
+        self.start_pos = self.place_agent(
+            top=(lWallIdx, 0),
+            size=(rWallIdx-lWallIdx, height)
         )
-        self.start_dir = self._randInt(0, 4)
 
         # Generate the mission string
         self.mission = (

+ 17 - 17
gym_minigrid/envs/multiroom.py

@@ -42,14 +42,14 @@ class MultiRoomEnv(MiniGridEnv):
         roomList = []
 
         # Choose a random number of rooms to generate
-        numRooms = self._randInt(self.minNumRooms, self.maxNumRooms+1)
+        numRooms = self._rand_int(self.minNumRooms, self.maxNumRooms+1)
 
         while len(roomList) < numRooms:
             curRoomList = []
 
             entryDoorPos = (
-                self._randInt(0, width - 2),
-                self._randInt(0, width - 2)
+                self._rand_int(0, width - 2),
+                self._rand_int(0, width - 2)
             )
 
             # Recursively place the rooms
@@ -99,7 +99,7 @@ class MultiRoomEnv(MiniGridEnv):
                     doorColors.remove(prevDoorColor)
                 # Note: the use of sorting here guarantees determinism,
                 # This is needed because Python's set is not deterministic
-                doorColor = self._randElem(sorted(doorColors))
+                doorColor = self._rand_elem(sorted(doorColors))
 
                 entryDoor = Door(doorColor)
                 self.grid.set(*room.entryDoorPos, entryDoor)
@@ -109,10 +109,10 @@ class MultiRoomEnv(MiniGridEnv):
                 prevRoom.exitDoorPos = room.entryDoorPos
 
         # Randomize the starting agent position and direction
-        self.placeAgent(roomList[0].top, roomList[0].size)
+        self.place_agent(roomList[0].top, roomList[0].size)
 
         # Place the final goal in the last room
-        self.placeObj(Goal(), roomList[-1].top, roomList[-1].size)
+        self.place_obj(Goal(), roomList[-1].top, roomList[-1].size)
 
         self.mission = 'traverse the rooms to get to the goal'
 
@@ -126,8 +126,8 @@ class MultiRoomEnv(MiniGridEnv):
         entryDoorPos
     ):
         # Choose the room size randomly
-        sizeX = self._randInt(minSz, maxSz+1)
-        sizeY = self._randInt(minSz, maxSz+1)
+        sizeX = self._rand_int(minSz, maxSz+1)
+        sizeY = self._rand_int(minSz, maxSz+1)
 
         # The first room will be at the door position
         if len(roomList) == 0:
@@ -136,21 +136,21 @@ class MultiRoomEnv(MiniGridEnv):
         elif entryDoorWall == 0:
             topX = entryDoorPos[0] - sizeX + 1
             y = entryDoorPos[1]
-            topY = self._randInt(y - sizeY + 2, y)
+            topY = self._rand_int(y - sizeY + 2, y)
         # Entry wall on the south
         elif entryDoorWall == 1:
             x = entryDoorPos[0]
-            topX = self._randInt(x - sizeX + 2, x)
+            topX = self._rand_int(x - sizeX + 2, x)
             topY = entryDoorPos[1] - sizeY + 1
         # Entry wall on the left
         elif entryDoorWall == 2:
             topX = entryDoorPos[0]
             y = entryDoorPos[1]
-            topY = self._randInt(y - sizeY + 2, y)
+            topY = self._rand_int(y - sizeY + 2, y)
         # Entry wall on the top
         elif entryDoorWall == 3:
             x = entryDoorPos[0]
-            topX = self._randInt(x - sizeX + 2, x)
+            topX = self._rand_int(x - sizeX + 2, x)
             topY = entryDoorPos[1]
         else:
             assert False, entryDoorWall
@@ -190,7 +190,7 @@ class MultiRoomEnv(MiniGridEnv):
             # Pick which wall to place the out door on
             wallSet = set((0, 1, 2, 3))
             wallSet.remove(entryDoorWall)
-            exitDoorWall = self._randElem(sorted(wallSet))
+            exitDoorWall = self._rand_elem(sorted(wallSet))
             nextEntryWall = (exitDoorWall + 2) % 4
 
             # Pick the exit door position
@@ -198,24 +198,24 @@ class MultiRoomEnv(MiniGridEnv):
             if exitDoorWall == 0:
                 exitDoorPos = (
                     topX + sizeX - 1,
-                    topY + self._randInt(1, sizeY - 1)
+                    topY + self._rand_int(1, sizeY - 1)
                 )
             # Exit on south wall
             elif exitDoorWall == 1:
                 exitDoorPos = (
-                    topX + self._randInt(1, sizeX - 1),
+                    topX + self._rand_int(1, sizeX - 1),
                     topY + sizeY - 1
                 )
             # Exit on left wall
             elif exitDoorWall == 2:
                 exitDoorPos = (
                     topX,
-                    topY + self._randInt(1, sizeY - 1)
+                    topY + self._rand_int(1, sizeY - 1)
                 )
             # Exit on north wall
             elif exitDoorWall == 3:
                 exitDoorPos = (
-                    topX + self._randInt(1, sizeX - 1),
+                    topX + self._rand_int(1, sizeX - 1),
                     topY
                 )
             else:

+ 14 - 14
gym_minigrid/envs/playground_v0.py

@@ -16,10 +16,10 @@ class PlaygroundV0(MiniGridEnv):
         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)
+        self.grid.horz_wall(0, 0)
+        self.grid.horz_wall(0, height-1)
+        self.grid.vert_wall(0, 0)
+        self.grid.vert_wall(width-1, 0)
 
         roomW = width // 3
         roomH = height // 3
@@ -36,33 +36,33 @@ class PlaygroundV0(MiniGridEnv):
 
                 # Bottom wall and door
                 if i+1 < 3:
-                    self.grid.vertWall(xR, yT, roomH)
-                    pos = (xR, self._randInt(yT+1, yB-1))
-                    color = self._randElem(COLOR_NAMES)
+                    self.grid.vert_wall(xR, yT, roomH)
+                    pos = (xR, self._rand_int(yT+1, yB-1))
+                    color = self._rand_elem(COLOR_NAMES)
                     self.grid.set(*pos, Door(color))
 
                 # Bottom wall and door
                 if j+1 < 3:
-                    self.grid.horzWall(xL, yB, roomW)
-                    pos = (self._randInt(xL+1, xR-1), yB)
-                    color = self._randElem(COLOR_NAMES)
+                    self.grid.horz_wall(xL, yB, roomW)
+                    pos = (self._rand_int(xL+1, xR-1), yB)
+                    color = self._rand_elem(COLOR_NAMES)
                     self.grid.set(*pos, Door(color))
 
         # Randomize the player start position and orientation
-        self.placeAgent()
+        self.place_agent()
 
         # Place random objects in the world
         types = ['key', 'ball', 'box']
         for i in range(0, 12):
-            objType = self._randElem(types)
-            objColor = self._randElem(COLOR_NAMES)
+            objType = self._rand_elem(types)
+            objColor = self._rand_elem(COLOR_NAMES)
             if objType == 'key':
                 obj = Key(objColor)
             elif objType == 'ball':
                 obj = Ball(objColor)
             elif objType == 'box':
                 obj = Box(objColor)
-            self.placeObj(obj)
+            self.place_obj(obj)
 
         # No explicit mission in this environment
         self.mission = ''

+ 10 - 10
gym_minigrid/envs/putnear.py

@@ -27,10 +27,10 @@ class PutNearEnv(MiniGridEnv):
         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)
+        self.grid.horz_wall(0, 0)
+        self.grid.horz_wall(0, height-1)
+        self.grid.vert_wall(0, 0)
+        self.grid.vert_wall(width-1, 0)
 
         # Types and colors of objects we can generate
         types = ['key', 'ball', 'box']
@@ -48,8 +48,8 @@ class PutNearEnv(MiniGridEnv):
 
         # Until we have generated all the objects
         while len(objs) < self.numObjs:
-            objType = self._randElem(types)
-            objColor = self._randElem(COLOR_NAMES)
+            objType = self._rand_elem(types)
+            objColor = self._rand_elem(COLOR_NAMES)
 
             # If this object already exists, try again
             if (objType, objColor) in objs:
@@ -62,22 +62,22 @@ class PutNearEnv(MiniGridEnv):
             elif objType == 'box':
                 obj = Box(objColor)
 
-            pos = self.placeObj(obj, reject_fn=near_obj)
+            pos = self.place_obj(obj, reject_fn=near_obj)
 
             objs.append((objType, objColor))
             objPos.append(pos)
 
         # Randomize the agent start position and orientation
-        self.placeAgent()
+        self.place_agent()
 
         # Choose a random object to be moved
-        objIdx = self._randInt(0, len(objs))
+        objIdx = self._rand_int(0, len(objs))
         self.move_type, self.moveColor = objs[objIdx]
         self.move_pos = objPos[objIdx]
 
         # Choose a target object (to put the first object next to)
         while True:
-            targetIdx = self._randInt(0, len(objs))
+            targetIdx = self._rand_int(0, len(objs))
             if targetIdx != objIdx:
                 break
         self.target_type, self.target_color = objs[targetIdx]

+ 9 - 9
gym_minigrid/envs/roomgrid.py

@@ -44,7 +44,7 @@ class RoomGrid(MiniGridEnv):
         self,
         room_size=6,
         num_cols=4,
-        max_steps=200
+        max_steps=100
     ):
         assert room_size > 0
         assert room_size >= 4
@@ -97,7 +97,7 @@ class RoomGrid(MiniGridEnv):
                 row.append(room)
 
                 # Generate the walls for this room
-                self.grid.wallRect(*room.top, *room.size)
+                self.grid.wall_rect(*room.top, *room.size)
 
             self.room_grid.append(row)
 
@@ -113,10 +113,10 @@ class RoomGrid(MiniGridEnv):
                 # Door positions, order is right, down, left, up
                 if i < self.num_cols - 1:
                     room.neighbors[0] = self.room_grid[j][i+1]
-                    room.door_pos[0] = (x_m, self._randInt(y_l, y_m))
+                    room.door_pos[0] = (x_m, self._rand_int(y_l, y_m))
                 if j < self.num_rows - 1:
                     room.neighbors[1] = self.room_grid[j+1][i]
-                    room.door_pos[1] = (self._randInt(x_l, x_m), y_m)
+                    room.door_pos[1] = (self._rand_int(x_l, x_m), y_m)
                 if i > 0:
                     room.neighbors[2] = self.room_grid[j][i-1]
                     room.door_pos[2] = room.neighbors[2].door_pos[0]
@@ -150,7 +150,7 @@ class RoomGrid(MiniGridEnv):
 
         room = self.get_room(i, j)
 
-        self.placeObj(obj, room.top, room.size, reject_fn)
+        self.place_obj(obj, room.top, room.size, reject_fn)
 
         room.objs.append(obj)
 
@@ -204,9 +204,9 @@ class RoomGrid(MiniGridEnv):
                 break
 
             # Pick a random room and door position
-            i = self._randInt(0, self.num_cols)
-            j = self._randInt(0, self.num_rows)
-            k = self._randInt(0, 4)
+            i = self._rand_int(0, self.num_cols)
+            j = self._rand_int(0, self.num_rows)
+            k = self._rand_int(0, 4)
             room = self.get_room(i, j)
 
             # If there is already a door there, skip
@@ -216,7 +216,7 @@ class RoomGrid(MiniGridEnv):
             if room.locked or room.neighbors[k].locked:
                 continue
 
-            color = self._randElem(COLOR_NAMES)
+            color = self._rand_elem(COLOR_NAMES)
             self.add_door(i, j, k, color)
 
     def step(self, action):

+ 37 - 37
gym_minigrid/minigrid.py

@@ -359,25 +359,25 @@ class Grid:
         assert j >= 0 and j < self.height
         return self.grid[j * self.width + i]
 
-    def horzWall(self, x, y, length=None):
+    def horz_wall(self, x, y, length=None):
         if length is None:
             length = self.width - x
         for i in range(0, length):
             self.set(x + i, y, Wall())
 
-    def vertWall(self, x, y, length=None):
+    def vert_wall(self, x, y, length=None):
         if length is None:
             length = self.height - y
         for j in range(0, length):
             self.set(x, y + j, Wall())
 
-    def wallRect(self, x, y, w, h):
-        self.horzWall(x, y, w)
-        self.horzWall(x, y+h-1, w)
-        self.vertWall(x, y, h)
-        self.vertWall(x+w-1, y, h)
+    def wall_rect(self, x, y, w, h):
+        self.horz_wall(x, y, w)
+        self.horz_wall(x, y+h-1, w)
+        self.vert_wall(x, y, h)
+        self.vert_wall(x+w-1, y, h)
 
-    def rotateLeft(self):
+    def rotate_left(self):
         """
         Rotate the grid to the left (counter-clockwise)
         """
@@ -413,15 +413,15 @@ class Grid:
 
         return grid
 
-    def render(self, r, tileSize):
+    def render(self, r, tile_size):
         """
         Render this grid at a given scale
         :param r: target renderer object
-        :param tileSize: tile size in pixels
+        :param tile_size: tile size in pixels
         """
 
-        assert r.width == self.width * tileSize
-        assert r.height == self.height * tileSize
+        assert r.width == self.width * tile_size
+        assert r.height == self.height * tile_size
 
         # Total grid size at native scale
         widthPx = self.width * CELL_PIXELS
@@ -445,7 +445,7 @@ class Grid:
 
         # Internally, we draw at the "large" full-grid resolution, but we
         # use the renderer to scale back to the desired size
-        r.scale(tileSize / CELL_PIXELS, tileSize / CELL_PIXELS)
+        r.scale(tile_size / CELL_PIXELS, tile_size / CELL_PIXELS)
 
         # Draw the background of the in-world cells black
         r.fillRect(
@@ -841,23 +841,23 @@ class MiniGridEnv(gym.Env):
     def _gen_grid(self, width, height):
         assert False, "_gen_grid needs to be implemented by each environment"
 
-    def _randInt(self, low, high):
+    def _rand_int(self, low, high):
         """
         Generate random integer in [low,high[
         """
 
         return self.np_random.randint(low, high)
 
-    def _randElem(self, iterable):
+    def _rand_elem(self, iterable):
         """
         Pick a random element in a list
         """
 
         lst = list(iterable)
-        idx = self._randInt(0, len(lst))
+        idx = self._rand_int(0, len(lst))
         return lst[idx]
 
-    def _randPos(self, xLow, xHigh, yLow, yHigh):
+    def _rand_pos(self, xLow, xHigh, yLow, yHigh):
         """
         Generate a random (x,y) position tuple
         """
@@ -867,7 +867,7 @@ class MiniGridEnv(gym.Env):
             self.np_random.randint(yLow, yHigh)
         )
 
-    def placeObj(self, obj, top=None, size=None, reject_fn=None):
+    def place_obj(self, obj, top=None, size=None, reject_fn=None):
         """
         Place an object at an empty position in the grid
 
@@ -884,8 +884,8 @@ class MiniGridEnv(gym.Env):
 
         while True:
             pos = (
-                self._randInt(top[0], top[0] + size[0]),
-                self._randInt(top[1], top[1] + size[1])
+                self._rand_int(top[0], top[0] + size[0]),
+                self._rand_int(top[1], top[1] + size[1])
             )
 
             # Don't place the object on top of another object
@@ -906,16 +906,16 @@ class MiniGridEnv(gym.Env):
 
         return pos
 
-    def placeAgent(self, top=None, size=None, randDir=True):
+    def place_agent(self, top=None, size=None, rand_dir=True):
         """
         Set the agent's starting point at an empty position in the grid
         """
 
-        pos = self.placeObj(None, top, size)
+        pos = self.place_obj(None, top, size)
         self.start_pos = pos
 
-        if randDir:
-            self.start_dir = self._randInt(0, 4)
+        if rand_dir:
+            self.start_dir = self._rand_int(0, 4)
 
         return pos
 
@@ -1030,10 +1030,10 @@ class MiniGridEnv(gym.Env):
 
         # Get the position in front of the agent
         u, v = self.get_dir_vec()
-        fwdPos = (self.agent_pos[0] + u, self.agent_pos[1] + v)
+        fwd_pos = (self.agent_pos[0] + u, self.agent_pos[1] + v)
 
         # Get the contents of the cell in front of the agent
-        fwdCell = self.grid.get(*fwdPos)
+        fwd_cell = self.grid.get(*fwd_pos)
 
         # Rotate left
         if action == self.actions.left:
@@ -1047,29 +1047,29 @@ class MiniGridEnv(gym.Env):
 
         # Move forward
         elif action == self.actions.forward:
-            if fwdCell == None or fwdCell.can_overlap():
-                self.agent_pos = fwdPos
-            if fwdCell != None and fwdCell.type == 'goal':
+            if fwd_cell == None or fwd_cell.can_overlap():
+                self.agent_pos = fwd_pos
+            if fwd_cell != None and fwd_cell.type == 'goal':
                 done = True
                 reward = 1000 - self.step_count
 
         # Pick up an object
         elif action == self.actions.pickup:
-            if fwdCell and fwdCell.can_pickup():
+            if fwd_cell and fwd_cell.can_pickup():
                 if self.carrying is None:
-                    self.carrying = fwdCell
-                    self.grid.set(*fwdPos, None)
+                    self.carrying = fwd_cell
+                    self.grid.set(*fwd_pos, None)
 
         # Drop an object
         elif action == self.actions.drop:
-            if not fwdCell and self.carrying:
-                self.grid.set(*fwdPos, self.carrying)
+            if not fwd_cell and self.carrying:
+                self.grid.set(*fwd_pos, self.carrying)
                 self.carrying = None
 
         # Toggle/activate an object
         elif action == self.actions.toggle:
-            if fwdCell:
-                fwdCell.toggle(self, fwdPos)
+            if fwd_cell:
+                fwd_cell.toggle(self, fwd_pos)
 
         # Wait/do nothing
         elif action == self.actions.wait:
@@ -1095,7 +1095,7 @@ class MiniGridEnv(gym.Env):
         grid = self.grid.slice(topX, topY, AGENT_VIEW_SIZE, AGENT_VIEW_SIZE)
 
         for i in range(self.agent_dir + 1):
-            grid = grid.rotateLeft()
+            grid = grid.rotate_left()
 
         # Make it so the agent sees what it's carrying
         # We do this by placing the carried object at the agent's position