in data/envs/babyai/bot_agent.py [0:0]
def _process_obs(self):
"""Parse the contents of an observation/image and update our state."""
grid, vis_mask = self.mission.unwrapped.gen_obs_grid()
view_size = self.mission.unwrapped.agent_view_size
pos = self.mission.unwrapped.agent_pos
f_vec = self.mission.unwrapped.dir_vec
r_vec = self.mission.unwrapped.right_vec
# Compute the absolute coordinates of the top-left corner
# of the agent's view area
top_left = pos + f_vec * (view_size - 1) - r_vec * (view_size // 2)
# Mark everything in front of us as visible
for vis_j in range(0, view_size):
for vis_i in range(0, view_size):
if not vis_mask[vis_i, vis_j]:
continue
# Compute the world coordinates of this cell
abs_i, abs_j = top_left - (f_vec * vis_j) + (r_vec * vis_i)
if abs_i < 0 or abs_i >= self.vis_mask.shape[0]:
continue
if abs_j < 0 or abs_j >= self.vis_mask.shape[1]:
continue
self.vis_mask[abs_i, abs_j] = True