def new_tasks(): location_d = d.get("location") repeat = get_repeat_num(d) tasks_to_do = [] if location_d is None: dance_fn = random.choice(list(self.memory.dances.values())) for i in range(repeat): dance_obj = dance.Movement(self.agent, dance_fn) t = tasks.Dance(self.agent, {"movement": dance_obj}) tasks_to_do.append(t) else: if "coref_resolve" in location_d: dance_fn = random.choice(list(self.memory.dances.values())) pos = interpret_location(self, speaker, location_d) for i in range(repeat): dance_obj = dance.Movement(agent=self.agent, move_fn=dance_fn, dance_location=pos) t = tasks.Dance(self.agent, {"movement": dance_obj}) tasks_to_do.append(t) elif "reference_object" in location_d: location_reference_object = location_d.get( "reference_object") objmems = interpret_reference_object( self, speaker, location_reference_object) if len(objmems) == 0: raise ErrorWithResponse( "I don't understand where you want me to go.") else: for i in range(repeat): refmove = dance.RefObjMovement( self.agent, ref_object=objmems[0], relative_direction=location_d[ "relative_direction"], ) t = tasks.Dance(self.agent, {"movement": refmove}) tasks_to_do.append(t) else: raise ErrorWithResponse( "I don't understand where you want me to go.") return list(reversed(tasks_to_do))
def new_tasks(): repeat = get_repeat_num(d) tasks_to_do = [] # only go around the x has "around"; FIXME allow other kinds of dances location_d = d.get("location") if location_d is not None: rd = location_d.get("relative_direction") if rd is not None and ( rd == "AROUND" or rd == "CLOCKWISE" or rd == "ANTICLOCKWISE" ): ref_obj = None location_reference_object = location_d.get("reference_object") if location_reference_object: objmems = self.subinterpret["reference_objects"]( self, speaker, location_reference_object ) if len(objmems) == 0: raise ErrorWithResponse("I don't understand where you want me to go.") ref_obj = objmems[0] for i in range(repeat): refmove = dance.RefObjMovement( self.agent, ref_object=ref_obj, relative_direction=location_d["relative_direction"], ) t = tasks.Dance(self.agent, {"movement": refmove}) tasks_to_do.append(t) return list(reversed(tasks_to_do)) dance_type = d.get("dance_type", {"dance_type_name": "dance"}) # FIXME holdover from old dict format if type(dance_type) is str: dance_type = dance_type = {"dance_type_name": "dance"} if dance_type.get("point"): target = interpret_point_target(self, speaker, dance_type["point"]) for i in range(repeat): t = tasks.Point(self.agent, {"target": target}) tasks_to_do.append(t) # MC bot does not control body turn separate from head elif dance_type.get("look_turn") or dance_type.get("body_turn"): lt = dance_type.get("look_turn") or dance_type.get("body_turn") f = interpret_facing(self, speaker, lt) for i in range(repeat): t = tasks.DanceMove(self.agent, f) tasks_to_do.append(t) else: if location_d is None: dance_location = None else: mems = interpret_reference_location(self, speaker, location_d) steps, reldir = interpret_relative_direction(self, location_d) dance_location, _ = compute_locations(self, speaker, mems, steps, reldir) # TODO use name! if dance_type.get("dance_type_span") is not None: dance_name = dance_type["dance_type_span"] if dance_name == "dance": dance_name = "ornamental_dance" dance_memids = self.memory._db_read( "SELECT DISTINCT(Dances.uuid) FROM Dances INNER JOIN Triples on Dances.uuid=Triples.subj WHERE Triples.obj_text=?", dance_name, ) else: dance_memids = self.memory._db_read( "SELECT DISTINCT(Dances.uuid) FROM Dances INNER JOIN Triples on Dances.uuid=Triples.subj WHERE Triples.obj_text=?", "ornamental_dance", ) dance_memid = random.choice(dance_memids)[0] dance_fn = self.memory.dances[dance_memid] for i in range(repeat): dance_obj = dance.Movement( agent=self.agent, move_fn=dance_fn, dance_location=dance_location ) t = tasks.Dance(self.agent, {"movement": dance_obj}) tasks_to_do.append(t) return list(reversed(tasks_to_do))
def new_tasks(): repeat = get_repeat_num(d) tasks_to_do = [] # only go around the x has "around"; FIXME allow other kinds of dances location_d = d.get("location") if location_d is not None: rd = location_d.get("relative_direction") if rd is not None and (rd == "AROUND" or rd == "CLOCKWISE" or rd == "ANTICLOCKWISE"): location_reference_object = location_d.get( "reference_object") if location_reference_object is None: ref_obj = "AGENT_POS" else: objmems = interpret_reference_object( self, speaker, location_reference_object) if len(objmems) == 0: raise ErrorWithResponse( "I don't understand where you want me to go.") ref_obj = objmems[0] for i in range(repeat): refmove = dance.RefObjMovement( self.agent, ref_object=ref_obj, relative_direction=location_d[ "relative_direction"], ) t = tasks.Dance(self.agent, {"movement": refmove}) tasks_to_do.append(t) return list(reversed(tasks_to_do)) dance_type = d.get("dance_type", {"dance_type_name": "dance"}) # FIXME holdover from old dict format if type(dance_type) is str: dance_type = dance_type = {"dance_type_name": "dance"} if dance_type.get("point"): target = interpret_point_target(self, speaker, dance_type["point"]) for i in range(repeat): t = tasks.Point(self.agent, {"target": target}) tasks_to_do.append(t) # MC bot does not control body turn separate from head elif dance_type.get("look_turn") or dance_type.get("body_turn"): try: lt = dance_type.get("look_turn") except: lt = dance_type.get("body_turn") f = interpret_facing(self, speaker, lt) for i in range(repeat): t = tasks.DanceMove(self.agent, f) tasks_to_do.append(t) else: if location_d is None: dance_location = None else: dance_location, _ = interpret_location( self, speaker, location_d) # TODO use name! dance_fn = random.choice(list(self.memory.dances.values())) for i in range(repeat): dance_obj = dance.Movement(agent=self.agent, move_fn=dance_fn, dance_location=dance_location) t = tasks.Dance(self.agent, {"movement": dance_obj}) tasks_to_do.append(t) return list(reversed(tasks_to_do))
def new_tasks(): repeat = get_repeat_num(d) tasks_to_do = [] # only go around the x has "around"; FIXME allow other kinds of dances location_d = d.get("location") if location_d is not None: rd = location_d.get("relative_direction") if rd is not None and (rd == "AROUND" or rd == "CLOCKWISE" or rd == "ANTICLOCKWISE"): ref_obj = None location_reference_object = location_d.get( "reference_object") if location_reference_object: objmems = self.subinterpret["reference_objects"]( self, speaker, location_reference_object) if len(objmems) == 0: raise ErrorWithResponse( "I don't understand where you want me to go.") ref_obj = objmems[0] for i in range(repeat): refmove = dance.RefObjMovement( self.agent, ref_object=ref_obj, relative_direction=location_d[ "relative_direction"], ) t = self.task_objects["dance"](self.agent, { "movement": refmove }) tasks_to_do.append(t) return maybe_task_list_to_control_block( tasks_to_do, self.agent) dance_type = d.get("dance_type", {}) if dance_type.get("point"): target = self.subinterpret["point_target"](self, speaker, dance_type["point"]) for i in range(repeat): t = self.task_objects["point"](self.agent, { "target": target }) tasks_to_do.append(t) # MC bot does not control body turn separate from head elif dance_type.get("look_turn") or dance_type.get("body_turn"): lt = dance_type.get("look_turn") or dance_type.get("body_turn") f = self.subinterpret["facing"](self, speaker, lt) for i in range(repeat): t = self.task_objects["dancemove"](self.agent, f) tasks_to_do.append(t) else: if location_d is None: dance_location = None else: mems = self.subinterpret["reference_locations"](self, speaker, location_d) steps, reldir = interpret_relative_direction( self, location_d) dance_location, _ = self.subinterpret["specify_locations"]( self, speaker, mems, steps, reldir) filters_d = dance_type.get("filters", {}) filters_d["memory_type"] = "DANCES" F = self.subinterpret["filters"](self, speaker, dance_type.get("filters", {})) dance_memids, _ = F() # TODO correct selector in filters dance_memid = random.choice(dance_memids) dance_mem = self.memory.get_mem_by_id(dance_memid) for i in range(repeat): dance_obj = dance.Movement(agent=self.agent, move_fn=dance_mem.dance_fn, dance_location=dance_location) t = self.task_objects["dance"](self.agent, { "movement": dance_obj }) tasks_to_do.append(t) return maybe_task_list_to_control_block(tasks_to_do, self.agent)