ソースを参照

Added object type for agent, changed FullyObsWrapper

Maxime Chevalier-Boisvert 6 年 前
コミット
09e330c76b
2 ファイル変更9 行追加3 行削除
  1. 2 1
      gym_minigrid/minigrid.py
  2. 7 2
      gym_minigrid/wrappers.py

+ 2 - 1
gym_minigrid/minigrid.py

@@ -43,7 +43,8 @@ OBJECT_TO_IDX = {
     'ball'          : 6,
     'box'           : 7,
     'goal'          : 8,
-    'lava'          : 9
+    'lava'          : 9,
+    'agent'         : 10,
 }
 
 IDX_TO_OBJECT = dict(zip(OBJECT_TO_IDX.values(), OBJECT_TO_IDX.keys()))

+ 7 - 2
gym_minigrid/wrappers.py

@@ -3,9 +3,9 @@ import operator
 from functools import reduce
 
 import numpy as np
-
 import gym
 from gym import error, spaces, utils
+from .minigrid import OBJECT_TO_IDX
 
 class ActionBonus(gym.core.Wrapper):
     """
@@ -111,7 +111,12 @@ class FullyObsWrapper(gym.core.ObservationWrapper):
     def observation(self, obs):
         env = self.unwrapped
         full_grid = env.grid.encode()
-        full_grid[env.agent_pos[0]][env.agent_pos[1]] = np.array([255, env.agent_dir, 0])
+        full_grid[env.agent_pos[0]][env.agent_pos[1]] = np.array([
+            OBJECT_TO_IDX['agent'],
+            env.agent_dir,
+            0
+        ])
+
         return full_grid
 
 class FlatObsWrapper(gym.core.ObservationWrapper):