in agent/nail.py [0:0]
def take_action(self, observation):
if self.env:
# Add true locations to the .log file.
loc = self.env.get_player_location()
if loc and hasattr(loc, 'num') and hasattr(loc, 'name') and loc.num and loc.name:
dbg("[TRUE_LOC] {} \"{}\"".format(loc.num, loc.name))
# Output a snapshot of the kg.
# with open(os.path.join(self.kgs_dir_path, str(self.step_num) + '.kng'), 'w') as f:
# f.write(str(self.knowledge_graph)+'\n\n')
# self.step_num += 1
observation = observation.strip()
if self.first_step:
dbg("[NAIL] {}".format(observation))
self.first_step = False
return 'look' # Do a look to get rid of intro text
if not kg.player_location:
loc = Location(observation)
kg.add_location(loc)
kg.player_location = loc
kg._init_loc = loc
self.consume_event_stream()
if not self.active_module:
self.elect_new_active_module()
next_action = self.generate_next_action(observation)
return next_action