|
@@ -20,7 +20,7 @@ class ReseedWrapper(Wrapper):
|
|
def __init__(self, env, seeds=[0], seed_idx=0):
|
|
def __init__(self, env, seeds=[0], seed_idx=0):
|
|
self.seeds = list(seeds)
|
|
self.seeds = list(seeds)
|
|
self.seed_idx = seed_idx
|
|
self.seed_idx = seed_idx
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
def reset(self, **kwargs):
|
|
def reset(self, **kwargs):
|
|
seed = self.seeds[self.seed_idx]
|
|
seed = self.seeds[self.seed_idx]
|
|
@@ -39,7 +39,7 @@ class ActionBonus(gym.Wrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env):
|
|
def __init__(self, env):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
self.counts = {}
|
|
self.counts = {}
|
|
|
|
|
|
def step(self, action):
|
|
def step(self, action):
|
|
@@ -73,7 +73,7 @@ class StateBonus(Wrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env):
|
|
def __init__(self, env):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
self.counts = {}
|
|
self.counts = {}
|
|
|
|
|
|
def step(self, action):
|
|
def step(self, action):
|
|
@@ -108,7 +108,7 @@ class ImgObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env):
|
|
def __init__(self, env):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
self.observation_space = env.observation_space.spaces["image"]
|
|
self.observation_space = env.observation_space.spaces["image"]
|
|
|
|
|
|
def observation(self, obs):
|
|
def observation(self, obs):
|
|
@@ -122,7 +122,7 @@ class OneHotPartialObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, tile_size=8):
|
|
def __init__(self, env, tile_size=8):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
self.tile_size = tile_size
|
|
self.tile_size = tile_size
|
|
|
|
|
|
@@ -162,7 +162,11 @@ class RGBImgObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, tile_size=8):
|
|
def __init__(self, env, tile_size=8):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
+
|
|
|
|
+ # Rendering attributes
|
|
|
|
+ self.highlight = True
|
|
|
|
+ self.tile_size = tile_size
|
|
|
|
|
|
self.tile_size = tile_size
|
|
self.tile_size = tile_size
|
|
|
|
|
|
@@ -178,9 +182,7 @@ class RGBImgObsWrapper(ObservationWrapper):
|
|
)
|
|
)
|
|
|
|
|
|
def observation(self, obs):
|
|
def observation(self, obs):
|
|
- env = self.unwrapped
|
|
|
|
-
|
|
|
|
- rgb_img = env.render(mode="rgb_array", highlight=True, tile_size=self.tile_size)
|
|
|
|
|
|
+ rgb_img = self.get_full_render()
|
|
|
|
|
|
return {**obs, "image": rgb_img}
|
|
return {**obs, "image": rgb_img}
|
|
|
|
|
|
@@ -192,8 +194,10 @@ class RGBImgPartialObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, tile_size=8):
|
|
def __init__(self, env, tile_size=8):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
|
|
+ # Rendering attributes
|
|
|
|
+ self.unwrapped.agent_pov = True
|
|
self.tile_size = tile_size
|
|
self.tile_size = tile_size
|
|
|
|
|
|
obs_shape = env.observation_space.spaces["image"].shape
|
|
obs_shape = env.observation_space.spaces["image"].shape
|
|
@@ -209,9 +213,7 @@ class RGBImgPartialObsWrapper(ObservationWrapper):
|
|
)
|
|
)
|
|
|
|
|
|
def observation(self, obs):
|
|
def observation(self, obs):
|
|
- env = self.unwrapped
|
|
|
|
-
|
|
|
|
- rgb_img_partial = env.get_obs_render(obs["image"], tile_size=self.tile_size)
|
|
|
|
|
|
+ rgb_img_partial = self.get_pov_render()
|
|
|
|
|
|
return {**obs, "image": rgb_img_partial}
|
|
return {**obs, "image": rgb_img_partial}
|
|
|
|
|
|
@@ -222,7 +224,7 @@ class FullyObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env):
|
|
def __init__(self, env):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
new_image_space = spaces.Box(
|
|
new_image_space = spaces.Box(
|
|
low=0,
|
|
low=0,
|
|
@@ -257,7 +259,7 @@ class DictObservationSpaceWrapper(ObservationWrapper):
|
|
word_dict is a dictionary of words to use (keys=words, values=indices from 1 to < max_words_in_mission),
|
|
word_dict is a dictionary of words to use (keys=words, values=indices from 1 to < max_words_in_mission),
|
|
if None, use the Minigrid language
|
|
if None, use the Minigrid language
|
|
"""
|
|
"""
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
if word_dict is None:
|
|
if word_dict is None:
|
|
word_dict = self.get_minigrid_words()
|
|
word_dict = self.get_minigrid_words()
|
|
@@ -370,7 +372,7 @@ class FlatObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, maxStrLen=96):
|
|
def __init__(self, env, maxStrLen=96):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
self.maxStrLen = maxStrLen
|
|
self.maxStrLen = maxStrLen
|
|
self.numCharCodes = 28
|
|
self.numCharCodes = 28
|
|
@@ -431,7 +433,7 @@ class ViewSizeWrapper(Wrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, agent_view_size=7):
|
|
def __init__(self, env, agent_view_size=7):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
assert agent_view_size % 2 == 1
|
|
assert agent_view_size % 2 == 1
|
|
assert agent_view_size >= 3
|
|
assert agent_view_size >= 3
|
|
@@ -466,7 +468,7 @@ class DirectionObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env, type="slope"):
|
|
def __init__(self, env, type="slope"):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
self.goal_position: tuple = None
|
|
self.goal_position: tuple = None
|
|
self.type = type
|
|
self.type = type
|
|
|
|
|
|
@@ -501,7 +503,7 @@ class SymbolicObsWrapper(ObservationWrapper):
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, env):
|
|
def __init__(self, env):
|
|
- super().__init__(env)
|
|
|
|
|
|
+ super().__init__(env, new_step_api=env.new_step_api)
|
|
|
|
|
|
new_image_space = spaces.Box(
|
|
new_image_space = spaces.Box(
|
|
low=0,
|
|
low=0,
|