in agent/decision_modules/interactor.py [0:0]
def get_eagerness(self):
if not self._active:
return 0.
self.best_action = None
self._eagerness = 0.
max_eagerness = 0.
# Consider single-object actions.
for entity in kg.player_location.entities + kg.inventory.entities:
for action, prob in self._affordance_extractor.extract_single_object_actions(entity):
if prob <= max_eagerness:
break
if entity.has_action_record(action) or \
(not action.recognized()) or \
(action in self.actions_that_caused_death) or \
((action.verb == 'take') and (entity in kg.inventory.entities)): # Need to promote to Take.
continue
max_eagerness = prob
self.best_action = action
break
# Consider double-object actions.
for entity1 in kg.player_location.entities + kg.inventory.entities:
for entity2 in kg.player_location.entities + kg.inventory.entities:
if entity1 != entity2:
for action, prob in self._affordance_extractor.extract_double_object_actions(entity1, entity2):
if prob <= max_eagerness:
break
if entity1.has_action_record(action) or \
(not action.recognized()) or \
(action in self.actions_that_caused_death):
continue
max_eagerness = prob
self.best_action = action
break
self._eagerness = max_eagerness
return self._eagerness