in agent/decision_modules/hoarder.py [0:0]
def parse_response(self, response):
here = gv.kg.player_location
success = False
for line in response.splitlines():
line = line.strip()
if ':' in line:
success = True
# Example - small mailbox: It's securly anchored.
entity_name, resp = [w.strip() for w in line.split(':', 1)]
short_name = entity_name.split(' ')[-1]
if here.has_entity_with_name(entity_name):
entity = here.get_entity_by_name(entity_name)
elif kg.inventory.has_entity_with_name(entity_name):
entity = kg.inventory.get_entity_by_name(entity_name)
else:
# Create the entity at the current location
entity = Entity(entity_name, here)
entity.add_name(short_name)
here.add_entity(entity)
take_action = gv.Take(entity)
p_valid = take_action.validate(resp)
dbg("[Take] p={:.2f} {} --> {}".format(p_valid, entity_name, resp))
entity.add_action_record(take_action, p_valid, resp)
if p_valid > 0.5:
take_action.apply()
self.record(success)