def come_to_player(agent): """Go to where the player is.""" op = agent.get_other_players() if len(op) == 0: return p = random.choice(agent.get_other_players()) agent.memory.task_stack_push(tasks.Move(agent, {"target": pos_to_np(p.pos), "approx": 3}))
def new_tasks(): location_d = d.get("location", {"location_type": "SPEAKER_LOOK"}) pos = interpret_location(self, speaker, location_d) if pos is None: raise ErrorWithResponse("I don't understand where you want me to move.") task_data = {"target": pos, "action_dict": d} task = tasks.Move(self.agent, task_data) return [task]
def get_move(self): if self.tick >= len(self.path): return None mv = tasks.Move(self.agent, { "target": self.path[self.tick], "approx": 2 }) self.tick += 1 return mv
def move_fn(danceObj, agent, dance_location): if danceObj.tick >= len(sequence): return None else: dpos = sequence[danceObj.tick] danceObj.tick += 1 target_location = dance_location if dance_location is not None else agent.pos target = target_location + dpos mv = tasks.Move(agent, {"target": target, "approx": 0}) return mv
def move_fn(danceObj, agent): if danceObj.tick >= len(sequence): return None else: if danceObj.dance_location is not None and danceObj.tick == 0: mv = tasks.Move(agent, {"target": danceObj.dance_location, "approx": 0}) danceObj.dance_location = None else: mv = tasks.DanceMove(agent, sequence[danceObj.tick]) danceObj.tick += 1 return mv
def new_tasks(): # TODO if we do this better will be able to handle "stay between the x" if self.loop_data and hasattr(self.loop_data, "get_pos"): pos = self.loop_data.get_pos() else: location_d = d.get("location", {"location_type": "SPEAKER_LOOK"}) pos, _ = interpret_location(self, speaker, location_d) if pos is None: raise ErrorWithResponse("I don't understand where you want me to move.") task_data = {"target": pos, "action_dict": d} task = tasks.Move(self.agent, task_data) return [task]
def new_tasks(): # TODO if we do this better will be able to handle "stay between the x" location_d = d.get("location", SPEAKERLOOK) if self.loop_data and hasattr(self.loop_data, "get_pos"): mems = [self.loop_data] else: mems = interpret_reference_location(self, speaker, location_d) steps, reldir = interpret_relative_direction(self, location_d) pos, _ = compute_locations(self, speaker, mems, steps, reldir) # TODO: can this actually happen? if pos is None: raise ErrorWithResponse("I don't understand where you want me to move.") task_data = {"target": pos, "action_dict": d} task = tasks.Move(self.agent, task_data) return [task]
def die(self): if self.dead: # This is possible if we entered a castle while dying, # which immediately disintegrates us. # Usually this isn't a problem, but explode() assumes # a not-None position. Of course, I could check that # directly, but I'd rather it fail loudly if the # assumption that living Entities have a position is # violated. return corpse = ExploderCorpse(self.pos, self.team) tasks.schedule(tasks.Move(corpse, None), 90) pos = self.pos tasks.Lambda(lambda: explode(pos), 60, tasks.THINK_PATIENCE) self.disintegrate()
def move_validated(self, pos): task = tasks.Move(self, pos) tasks.immediately(tasks.ACT_PATIENCE, task) self.has_task(task)
def die(self): corpse = Corpse(self.pos, self.team) tasks.schedule(tasks.Move(corpse, None), 90) self.disintegrate()
def test_move(self): self.memory.task_stack_push(tasks.Move(self.agent, {"target": (42, 42, 42)})) self.memory.add_chat("test_agent", "test chat: where are you going?") self.dialogue_stack.step() self.agent.send_chat.assert_called()