Skip to content

Commit

Permalink
use reason='Unlock' also when exploring
Browse files Browse the repository at this point in the history
  • Loading branch information
rizar committed Jan 29, 2019
1 parent 1917189 commit e7a5b8f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions babyai/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ class GoNextToSubgoal(Subgoal):
Parameters:
----------
datum : (int, int) tuple or `ObjDesc`
The position or the object to which we are going:
datum : (int, int) tuple or `ObjDesc` or object reference
The position or the decription of the object or
the object to which we are going.
reason : str
One of the following:
- `None`: go the position (object) and face it
Expand All @@ -291,6 +292,9 @@ def replan_before_action(self):
# No path found -> Explore the world
self.bot.stack.append(ExploreSubgoal(self.bot))
return
elif isinstance(self.datum, WorldObj):
target_obj = self.datum
target_pos = target_obj.cur_pos
else:
target_pos = tuple(self.datum)

Expand Down Expand Up @@ -475,9 +479,11 @@ def unopened_door(pos, cell):

# Open the door
if door_pos:
door_obj = self.bot.mission.grid.get(*door_pos)
self.bot.stack.pop()
self.bot.stack.append(OpenSubgoal(self.bot))
self.bot.stack.append(GoNextToSubgoal(self.bot, door_pos))
self.bot.stack.append(OpenSubgoal(
self.bot, reason='Unlock' if door_obj.is_locked else None))
self.bot.stack.append(GoNextToSubgoal(self.bot, door_obj, reason='Open'))
return

assert False, "0nothing left to explore"
Expand Down

0 comments on commit e7a5b8f

Please sign in to comment.