in data/envs/babyai/bot_agent.py [0:0]
def _closest_wall_or_door_given_dir(self, position, direction):
distance = 1
while True:
position_to_try = position + distance * direction
# If the current position is outside the field of view,
# stop everything and return the previous one
if not self.mission.unwrapped.in_view(*position_to_try):
return distance - 1
cell = self.mission.unwrapped.grid.get(*position_to_try)
if cell and (cell.type.endswith("door") or cell.type == "wall"):
return distance
distance += 1