@@ -24,20 +24,20 @@ class ReseedWrapper(Wrapper):
2424 >>> from minigrid.wrappers import ReseedWrapper
2525 >>> env = gym.make("MiniGrid-Empty-5x5-v0")
2626 >>> _ = env.reset(seed=123)
27- >>> [env.np_random.integers(10) for i in range(10)]
27+ >>> [env.np_random.integers(10).item() for i in range(10)]
2828 [0, 6, 5, 0, 9, 2, 2, 1, 3, 1]
2929 >>> env = ReseedWrapper(env, seeds=[0, 1], seed_idx=0)
3030 >>> _, _ = env.reset()
31- >>> [env.np_random.integers(10) for i in range(10)]
31+ >>> [env.np_random.integers(10).item() for i in range(10)]
3232 [8, 6, 5, 2, 3, 0, 0, 0, 1, 8]
3333 >>> _, _ = env.reset()
34- >>> [env.np_random.integers(10) for i in range(10)]
34+ >>> [env.np_random.integers(10).item() for i in range(10)]
3535 [4, 5, 7, 9, 0, 1, 8, 9, 2, 3]
3636 >>> _, _ = env.reset()
37- >>> [env.np_random.integers(10) for i in range(10)]
37+ >>> [env.np_random.integers(10).item() for i in range(10)]
3838 [8, 6, 5, 2, 3, 0, 0, 0, 1, 8]
3939 >>> _, _ = env.reset()
40- >>> [env.np_random.integers(10) for i in range(10)]
40+ >>> [env.np_random.integers(10).item() for i in range(10)]
4141 [4, 5, 7, 9, 0, 1, 8, 9, 2, 3]
4242 """
4343
@@ -325,7 +325,7 @@ def __init__(self, env, tile_size=8):
325325 )
326326
327327 def observation (self , obs ):
328- rgb_img = self .get_frame (
328+ rgb_img = self .unwrapped . get_frame (
329329 highlight = self .unwrapped .highlight , tile_size = self .tile_size
330330 )
331331
@@ -374,7 +374,9 @@ def __init__(self, env, tile_size=8):
374374 )
375375
376376 def observation (self , obs ):
377- rgb_img_partial = self .get_frame (tile_size = self .tile_size , agent_pov = True )
377+ rgb_img_partial = self .unwrapped .get_frame (
378+ tile_size = self .tile_size , agent_pov = True
379+ )
378380
379381 return {** obs , "image" : rgb_img_partial }
380382
@@ -403,7 +405,11 @@ def __init__(self, env):
403405 new_image_space = spaces .Box (
404406 low = 0 ,
405407 high = 255 ,
406- shape = (self .env .width , self .env .height , 3 ), # number of cells
408+ shape = (
409+ self .env .unwrapped .width ,
410+ self .env .unwrapped .height ,
411+ 3 ,
412+ ), # number of cells
407413 dtype = "uint8" ,
408414 )
409415
@@ -680,7 +686,7 @@ class DirectionObsWrapper(ObservationWrapper):
680686 >>> env = gym.make("MiniGrid-LavaCrossingS11N5-v0")
681687 >>> env_obs = DirectionObsWrapper(env, type="slope")
682688 >>> obs, _ = env_obs.reset()
683- >>> obs['goal_direction']
689+ >>> obs['goal_direction'].item()
684690 1.0
685691 """
686692
@@ -696,21 +702,21 @@ def reset(
696702
697703 if not self .goal_position :
698704 self .goal_position = [
699- x for x , y in enumerate (self .grid .grid ) if isinstance (y , Goal )
705+ x for x , y in enumerate (self .unwrapped . grid .grid ) if isinstance (y , Goal )
700706 ]
701707 # in case there are multiple goals , needs to be handled for other env types
702708 if len (self .goal_position ) >= 1 :
703709 self .goal_position = (
704- int (self .goal_position [0 ] / self .height ),
705- self .goal_position [0 ] % self .width ,
710+ int (self .goal_position [0 ] / self .unwrapped . height ),
711+ self .goal_position [0 ] % self .unwrapped . width ,
706712 )
707713
708714 return self .observation (obs ), info
709715
710716 def observation (self , obs ):
711717 slope = np .divide (
712- self .goal_position [1 ] - self .agent_pos [1 ],
713- self .goal_position [0 ] - self .agent_pos [0 ],
718+ self .goal_position [1 ] - self .unwrapped . agent_pos [1 ],
719+ self .goal_position [0 ] - self .unwrapped . agent_pos [0 ],
714720 )
715721
716722 if self .type == "angle" :
@@ -746,7 +752,11 @@ def __init__(self, env):
746752 new_image_space = spaces .Box (
747753 low = 0 ,
748754 high = max (OBJECT_TO_IDX .values ()),
749- shape = (self .env .width , self .env .height , 3 ), # number of cells
755+ shape = (
756+ self .env .unwrapped .width ,
757+ self .env .unwrapped .height ,
758+ 3 ,
759+ ), # number of cells
750760 dtype = "uint8" ,
751761 )
752762 self .observation_space = spaces .Dict (
@@ -755,10 +765,13 @@ def __init__(self, env):
755765
756766 def observation (self , obs ):
757767 objects = np .array (
758- [OBJECT_TO_IDX [o .type ] if o is not None else - 1 for o in self .grid .grid ]
768+ [
769+ OBJECT_TO_IDX [o .type ] if o is not None else - 1
770+ for o in self .unwrapped .grid .grid
771+ ]
759772 )
760- agent_pos = self .env .agent_pos
761- ncol , nrow = self .width , self .height
773+ agent_pos = self .env .unwrapped . agent_pos
774+ ncol , nrow = self .unwrapped . width , self . unwrapped .height
762775 grid = np .mgrid [:ncol , :nrow ]
763776 _objects = np .transpose (objects .reshape (1 , nrow , ncol ), (0 , 2 , 1 ))
764777
@@ -849,9 +862,9 @@ def __init__(self, env, no_death_types: tuple[str, ...], death_cost: float = -1.
849862 def step (self , action ):
850863 # In Dynamic-Obstacles, obstacles move after the agent moves,
851864 # so we need to check for collision before self.env.step()
852- front_cell = self .grid .get (* self .front_pos )
865+ front_cell = self .unwrapped . grid .get (* self . unwrapped .front_pos )
853866 going_to_death = (
854- action == self .actions .forward
867+ action == self .unwrapped . actions .forward
855868 and front_cell is not None
856869 and front_cell .type in self .no_death_types
857870 )
@@ -860,7 +873,7 @@ def step(self, action):
860873
861874 # We also check if the agent stays in death cells (e.g., lava)
862875 # without moving
863- current_cell = self .grid .get (* self .agent_pos )
876+ current_cell = self .unwrapped . grid .get (* self . unwrapped .agent_pos )
864877 in_death = current_cell is not None and current_cell .type in self .no_death_types
865878
866879 if terminated and (going_to_death or in_death ):
0 commit comments