浏览代码

Added check for invalid actions to dynamic obstacles.

In response to #63
Maxime Chevalier-Boisvert 6 年之前
父节点
当前提交
f3db6a7613
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      gym_minigrid/envs/dynamicobstacles.py

+ 4 - 0
gym_minigrid/envs/dynamicobstacles.py

@@ -60,6 +60,10 @@ class DynamicObstaclesEnv(MiniGridEnv):
         self.mission = "get to the green goal square"
         self.mission = "get to the green goal square"
 
 
     def step(self, action):
     def step(self, action):
+        # Invalid action
+        if action >= self.action_space.n:
+            action = 0
+
         obs, reward, done, info = MiniGridEnv.step(self, action)
         obs, reward, done, info = MiniGridEnv.step(self, action)
 
 
         # Update obstacle positions
         # Update obstacle positions