浏览代码

Added color names list to minigrid.py

Maxime Chevalier-Boisvert 7 年之前
父节点
当前提交
f2dd5adfc3
共有 2 个文件被更改,包括 4 次插入3 次删除
  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,