Example #1
0
 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
Example #2
0
        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))
Example #3
0
        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))