in agent/decision_modules/interactor.py [0:0]
def take_control(self):
obs = yield
# Failsafe checks
if self._eagerness == 0.: # Should never happen anyway.
self.get_eagerness() # But if it does, try finding a best action.
if self._eagerness == 0.:
return # If no good action can be found, simply return without yielding.
action = self.best_action
self.best_action = None
self._eagerness = 0.
response = yield action
p_valid = action.validate(response)
if p_valid is None:
p_valid = self._valid_detector.action_valid(action, first_sentence(response))
if isinstance(action, SingleAction):
action.entity.add_action_record(action, p_valid, response)
elif isinstance(action, DoubleAction):
action.entity1.add_action_record(action, p_valid, response)
success = (p_valid > 0.5)
self.record(success)
if success:
action.apply()
dbg("[INT]({}) p={:.2f} {} --> {}".format(
"val" if success else "inv", p_valid, action, response))
if ('RESTART' in response and 'RESTORE' in response and 'QUIT' in response) or ('You have died' in response):
if action not in self.actions_that_caused_death:
self.actions_that_caused_death[action] = True # Remember actions that cause death.