Browse Source

Fixed bug in place_agent

Maxime Chevalier-Boisvert 7 years ago
parent
commit
342b3c96f1
2 changed files with 5 additions and 0 deletions
  1. 1 0
      gym_minigrid/minigrid.py
  2. 4 0
      run_tests.py

+ 1 - 0
gym_minigrid/minigrid.py

@@ -869,6 +869,7 @@ class MiniGridEnv(gym.Env):
         Set the agent's starting point at an empty position in the grid
         """
 
+        self.start_pos = None
         pos = self.place_obj(None, top, size)
         self.start_pos = pos
 

+ 4 - 0
run_tests.py

@@ -43,6 +43,10 @@ for envName in env_list:
 
         obs, reward, done, info = env.step(action)
 
+        # Validate the agent position
+        assert env.agent_pos[0] < env.grid_size
+        assert env.agent_pos[1] < env.grid_size
+
         # Test observation encode/decode roundtrip
         img = obs['image']
         grid = Grid.decode(img)