in agent/decision_modules/navigator.py [0:0]
def get_action(self):
"""
First try to take an unexplored nav action. If none exist, sample one
of the successful or failed nav actions.
"""
loc = kg.player_location
# If there was a previously suggested direction, try it
if self._suggested_directions:
act = rng.choice(self._suggested_directions)
del self._suggested_directions[:]
dbg("[NAV] Trying suggested action: {}".format(act))
return act
# First try to move in one of the directions mentioned in the description.
likely_nav_actions = self.get_mentioned_directions(loc.description)
for act in likely_nav_actions:
if not loc.has_action_record(act):
dbg("[NAV] Trying mentioned action: {}".format(act))
return act
# Then try something new
unexplored = self.get_unexplored_actions(loc)
if unexplored:
act = rng.choice(unexplored)
dbg("[NAV] Trying unexplored action: {}".format(act))
return act
# Try a previously successful action
if rng.random() > self._p_retry:
successful_actions = self.get_successful_nav_actions(loc)
if successful_actions:
act = rng.choice(successful_actions)
dbg("[NAV] Trying previously successful action: {}".format(act))
return act
# Finally, just try something random
act = rng.choice(self._nav_actions)
dbg("[NAV] Trying random action: {}".format(act))
return act