File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed
gymnasium_robotics/envs/maze Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -218,12 +218,11 @@ def reset(
218
218
assert self .maze .map_length > options ["goal_cell" ][1 ]
219
219
assert self .maze .map_width > options ["goal_cell" ][0 ]
220
220
assert (
221
- self .maze .maze_map [options ["goal_cell" ][1 ], options ["goal_cell" ][0 ]]
221
+ self .maze .maze_map [options ["goal_cell" ][1 ]][ options ["goal_cell" ][0 ]]
222
222
!= 1
223
223
), f"Goal can't be placed in a wall cell, { options ['goal_cell' ]} "
224
224
225
225
goal = self .maze .cell_rowcol_to_xy (options ["goal_cell" ])
226
-
227
226
else :
228
227
goal = self .generate_target_goal ()
229
228
@@ -235,8 +234,8 @@ def reset(
235
234
assert self .maze .map_length > options ["reset_cell" ][1 ]
236
235
assert self .maze .map_width > options ["reset_cell" ][0 ]
237
236
assert (
238
- self .maze .maze_map [
239
- options ["reset_cell" ][1 ], options [ "reset_cell" ][ 0 ]
237
+ self .maze .maze_map [options [ "reset_cell" ][ 1 ]][
238
+ options ["reset_cell" ][0 ]
240
239
]
241
240
!= 1
242
241
), f"Reset can't be placed in a wall cell, { options ['reset_cell' ]} "
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ def reset(
295
295
assert self .maze .map_length > options ["goal_cell" ][1 ]
296
296
assert self .maze .map_width > options ["goal_cell" ][0 ]
297
297
assert (
298
- self .maze .maze_map [options ["goal_cell" ][1 ], options ["goal_cell" ][0 ]]
298
+ self .maze .maze_map [options ["goal_cell" ][1 ]][ options ["goal_cell" ][0 ]]
299
299
!= 1
300
300
), f"Goal can't be placed in a wall cell, { options ['goal_cell' ]} "
301
301
@@ -312,8 +312,8 @@ def reset(
312
312
assert self .maze .map_length > options ["reset_cell" ][1 ]
313
313
assert self .maze .map_width > options ["reset_cell" ][0 ]
314
314
assert (
315
- self .maze .maze_map [
316
- options ["reset_cell" ][1 ], options [ "reset_cell" ][ 0 ]
315
+ self .maze .maze_map [options [ "reset_cell" ][ 1 ]][
316
+ options ["reset_cell" ][0 ]
317
317
]
318
318
!= 1
319
319
), f"Reset can't be placed in a wall cell, { options ['reset_cell' ]} "
Original file line number Diff line number Diff line change @@ -11,3 +11,31 @@ def test_reset():
11
11
assert not info ["success" ]
12
12
dist = np .linalg .norm (obs ["achieved_goal" ] - obs ["desired_goal" ])
13
13
assert dist > 0.45 , f"dist={ dist } < 0.45"
14
+
15
+
16
+ def test_reset_cell ():
17
+ """Check that passing the reset_cell location ensures that the agent resets in the right cell."""
18
+ map = [
19
+ [1 , 1 , 1 , 1 ],
20
+ [1 , "r" , "r" , 1 ],
21
+ [1 , "r" , "g" , 1 ],
22
+ [1 , 1 , 1 , 1 ],
23
+ ]
24
+ env = gym .make ("PointMaze_UMaze-v3" , maze_map = map )
25
+ obs = env .reset (options = {"reset_cell" : [1 , 2 ]}, seed = 42 )[0 ]
26
+ desired_obs = np .array ([0.67929896 , 0.59868401 , 0 , 0 ])
27
+ np .testing .assert_almost_equal (desired_obs , obs ["observation" ], decimal = 4 )
28
+
29
+
30
+ def test_goal_cell ():
31
+ """Check that passing the goal_cell location ensures that the goal spawns in the right cell."""
32
+ map = [
33
+ [1 , 1 , 1 , 1 ],
34
+ [1 , "r" , "g" , 1 ],
35
+ [1 , "g" , "g" , 1 ],
36
+ [1 , 1 , 1 , 1 ],
37
+ ]
38
+ env = gym .make ("PointMaze_UMaze-v3" , maze_map = map )
39
+ obs = env .reset (options = {"goal_cell" : [2 , 1 ]}, seed = 42 )[0 ]
40
+ desired_goal = np .array ([- 0.36302198 , - 0.53056078 ])
41
+ np .testing .assert_almost_equal (desired_goal , obs ["desired_goal" ], decimal = 4 )
You can’t perform that action at this time.
0 commit comments