Skip to content

Commit

Permalink
Attempt to fix issue mila-iqia#22, agent starting in locked room
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Jan 19, 2019
1 parent 8431f26 commit 07ddcd0
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions babyai/levels/iclr19_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ class Level_GoToImpUnlock(RoomGridLevel):
"""

def gen_mission(self):
self.place_agent()

# Add a locked door to a random room
id = self._rand_int(0, self.num_rows)
jd = self._rand_int(0, self.num_cols)
Expand Down Expand Up @@ -336,6 +334,16 @@ def gen_mission(self):
num_distractors=2,
all_unique=False
)

# The agent must be placed after all the object to respect constraints
while True:
self.place_agent()
start_room = self.room_from_pos(*self.start_pos)
# Ensure that we are not placing the agent in the locked room
if start_room is locked_room:
continue
break

self.check_objs_reachable()

# Add a single object to the locked room
Expand Down Expand Up @@ -410,8 +418,6 @@ class Level_Unlock(RoomGridLevel):
"""

def gen_mission(self):
self.place_agent()

# Add a locked door to a random room
id = self._rand_int(0, self.num_rows)
jd = self._rand_int(0, self.num_cols)
Expand Down Expand Up @@ -448,6 +454,16 @@ def gen_mission(self):
num_distractors=3,
all_unique=False
)

# The agent must be placed after all the object to respect constraints
while True:
self.place_agent()
start_room = self.room_from_pos(*self.start_pos)
# Ensure that we are not placing the agent in the locked room
if start_room is locked_room:
continue
break

self.check_objs_reachable()

self.instrs = OpenInstr(ObjDesc(door.type, door.color))
Expand Down

0 comments on commit 07ddcd0

Please sign in to comment.