in minihack/envs/minigrid.py [0:0]
def get_env_map(self, env):
door_pos = []
goal_pos = None
empty_strs = 0
empty_str = True
env_map = []
for j in range(env.grid.height):
str = ""
for i in range(env.width):
c = env.grid.get(i, j)
if c is None:
str += "."
continue
empty_str = False
if c.type == "wall":
str += self.wall
elif c.type == "door":
str += "+"
door_pos.append((i, j - empty_strs))
elif c.type == "floor":
str += "."
elif c.type == "lava":
str += "L"
elif c.type == "goal":
goal_pos = (i, j - empty_strs)
str += "."
elif c.type == "player":
str += "."
if not empty_str and j < env.grid.height - 1:
if set(str) != {"."}:
str = str.replace(".", " ", str.index(self.wall))
inv = str[::-1]
str = inv.replace(".", " ", inv.index(self.wall))[::-1]
env_map.append(str)
elif empty_str:
empty_strs += 1
start_pos = (int(env.agent_pos[0]), int(env.agent_pos[1]) - empty_strs)
env_map = "\n".join(env_map)
return env_map, start_pos, goal_pos, door_pos