Browse Source

Added color names list to minigrid.py

Maxime Chevalier-Boisvert 7 years ago
parent
commit
f2dd5adfc3
2 changed files with 4 additions and 3 deletions
  1. 1 3
      gym_minigrid/envs/gotodoor.py
  2. 3 0
      gym_minigrid/minigrid.py

+ 1 - 3
gym_minigrid/envs/gotodoor.py

@@ -37,8 +37,6 @@ class GoToDoorEnv(MiniGridEnv):
             grid.set(0, j, Wall())
             grid.set(width-1, j, Wall())
 
-        colors = list(COLORS.keys())
-
         # Generate the 4 doors at random positions
         doorPos = []
         doorPos.append((self._randInt(2, width-2), 0))
@@ -49,7 +47,7 @@ class GoToDoorEnv(MiniGridEnv):
         # Generate the door colors
         doorColors = []
         while len(doorColors) < len(doorPos):
-            color = self._randElem(colors)
+            color = self._randElem(COLOR_NAMES)
             if color in doorColors:
                 continue
             doorColors.append(color)

+ 3 - 0
gym_minigrid/minigrid.py

@@ -15,6 +15,7 @@ AGENT_VIEW_SIZE = 7
 # Size of the array given as an observation to the agent
 OBS_ARRAY_SIZE = (AGENT_VIEW_SIZE, AGENT_VIEW_SIZE, 3)
 
+# Map of color names to RGB values
 COLORS = {
     'red'   : (255, 0, 0),
     'green' : (0, 255, 0),
@@ -24,6 +25,8 @@ COLORS = {
     'grey'  : (100, 100, 100)
 }
 
+COLOR_NAMES = list(COLORS.keys())
+
 # Used to map colors to integers
 COLOR_TO_IDX = {
     'red'   : 0,