Пример #1
0
 def role_requirements(self):
     reqs = super().role_requirements()
     if 'move' in reqs:
         for r in role_assignment.iterate_role_requirements_tree_leaves(reqs['move']):
             r.chipper_preference_weight = role_assignment.PreferChipper
     if 'kicker' in reqs:
         for r in role_assignment.iterate_role_requirements_tree_leaves(reqs['kicker']):
             r.previous_shell_id = self._kicker_shell_id
     return reqs
Пример #2
0
    def role_requirements(self):
        reqs = super().role_requirements()

        for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            req.required_shell_id = self.shell_id

        return reqs
Пример #3
0
 def role_requirements(self):
     reqs = super().role_requirements()
     if self.shell_id != None:
         for req in role_assignment.iterate_role_requirements_tree_leaves(
                 reqs):
             req.previous_shell_id = self.shell_id
     return reqs
    def assign_roles(self, assignments):
        oldBot = self.robot
        if self.has_subbehaviors():
            composite_behavior.CompositeBehavior.assign_roles(
                self, assignments)

            # extract robot from the one leaf in the tree
            # we don't know how deep the tree is, which is why we use the tree leaf iterator
            for assignment_tuple in role_assignment.iterate_role_requirements_tree_leaves(
                    assignments):
                self.robot = assignment_tuple[1]
        else:
            single_robot_behavior.SingleRobotBehavior.assign_roles(
                self, assignments)

        # Most single robot composite behaviors assume (rightly so) that the robot they're
        # dealing with won't change. PivotKick for example runs the Capture skill, then
        # the Aim skill to do its stuff. It'd be pretty weird if the robot executing Aim
        # was different from the one that just ran Capture. Here we just restart the behavior
        # If it gets assigned a new robot.
        if oldBot != None and self.robot != None and oldBot.shell_id(
        ) != self.robot.shell_id():
            logging.info(
                "SingleRobotCompositeBehavior: robot changed, restarting behavior"
            )
            self.restart()
 def role_requirements(self):
     reqs = super().role_requirements()
     if self.shell_id != None:
         for req in role_assignment.iterate_role_requirements_tree_leaves(
                 reqs):
             req.previous_shell_id = self.shell_id
     return reqs
    def assign_roles(self, assignments):
        oldBot = self.robot
        if self.has_subbehaviors():
            composite_behavior.CompositeBehavior.assign_roles(
                self, assignments)

            # extract robot from the one leaf in the tree
            # we don't know how deep the tree is, which is why we use the tree leaf iterator
            for assignment_tuple in role_assignment.iterate_role_requirements_tree_leaves(
                    assignments):
                self.robot = assignment_tuple[1]
        else:
            single_robot_behavior.SingleRobotBehavior.assign_roles(
                self, assignments)

        # Sometimes the robot executing a single_robot_composite_behavior changes in the
        # middle of the behavior. For some plays, this means we shouild restart the whole
        # behavior for the new robot (autorestart = True). For others, it is more important to continue the new
        # robot where the old robot left off (autorestart = False).
        if (oldBot is not None and self.robot is not None
                and oldBot.shell_id() != self.robot.shell_id()
                and self.autorestart()):
            logging.info("SingleRobotCompositeBehavior: robot changed (" +
                         str(oldBot.shell_id()) + "->" +
                         str(self.robot.shell_id()) + "), restarting: " +
                         type(self).__name__)
            self.restart()
    def assign_roles(self, assignments):
        oldBot = self.robot
        if self.has_subbehaviors():
            composite_behavior.CompositeBehavior.assign_roles(self,
                                                              assignments)

            # extract robot from the one leaf in the tree
            # we don't know how deep the tree is, which is why we use the tree leaf iterator
            for assignment_tuple in role_assignment.iterate_role_requirements_tree_leaves(
                assignments):
                self.robot = assignment_tuple[1]
        else:
            single_robot_behavior.SingleRobotBehavior.assign_roles(self,
                                                                   assignments)

        # Sometimes the robot executing a single_robot_composite_behavior changes in the
        # middle of the behavior. For some plays, this means we shouild restart the whole
        # behavior for the new robot (autorestart = True). For others, it is more important to continue the new
        # robot where the old robot left off (autorestart = False).
        if (oldBot is not None and self.robot is not None and
                oldBot.shell_id() != self.robot.shell_id() and
                self.autorestart()):
            logging.info("SingleRobotCompositeBehavior: robot changed (" + str(
                oldBot.shell_id()) + "->" + str(self.robot.shell_id()) +
                         "), restarting: " + type(self).__name__)
            self.restart()
Пример #8
0
    def role_requirements(self):
        reqs = super().role_requirements()

        for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            req.required_shell_id = self.shell_id if self.shell_id != None else -1

        return reqs
    def assign_roles(self, assignments):
        oldBot = self.robot
        if self.has_subbehaviors():
            composite_behavior.CompositeBehavior.assign_roles(self,
                                                              assignments)

            # extract robot from the one leaf in the tree
            # we don't know how deep the tree is, which is why we use the tree leaf iterator
            for assignment_tuple in role_assignment.iterate_role_requirements_tree_leaves(
                    assignments):
                self.robot = assignment_tuple[1]
        else:
            single_robot_behavior.SingleRobotBehavior.assign_roles(self,
                                                                   assignments)

        # Most single robot composite behaviors assume (rightly so) that the robot they're
        # dealing with won't change. PivotKick for example runs the Capture skill, then
        # the Aim skill to do its stuff. It'd be pretty weird if the robot executing Aim
        # was different from the one that just ran Capture. Here we just restart the behavior
        # If it gets assigned a new robot.
        if oldBot != None and self.robot != None and oldBot.shell_id(
        ) != self.robot.shell_id():
            logging.info(
                "SingleRobotCompositeBehavior: robot changed, restarting behavior")
            self.restart()
Пример #10
0
 def role_requirements(self):
     reqs = super().role_requirements()
     for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
         if self.receive_point != None:
             req.destination_shape = self.receive_point
         elif self.receive_point != None:
             req.destination_shape = self.receive_point
     return reqs
Пример #11
0
 def role_requirements(self):
     reqs = super().role_requirements()
     for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
         if self._target_pos != None:
             req.destination_shape = self._target_pos
         elif self.receive_point != None:
             req.destination_shape = self.receive_point
     return reqs
    def role_requirements(self):
        if self.has_subbehaviors():
            reqs = composite_behavior.CompositeBehavior.role_requirements(self)
            if self.robot != None:
                for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
                    req.previous_shell_id = self.robot.shell_id()

            return reqs
        else:
            return single_robot_behavior.SingleRobotBehavior.role_requirements(self)
Пример #13
0
 def role_requirements(self):
     # forces all subbhehaviors to use the same robot
     if len(self.behaviors) > 0 and self.robot is not None:
         reqs = behavior_sequence.BehaviorSequence.role_requirements(self)
         for req in role_assignment.iterate_role_requirements_tree_leaves(
                 reqs):
             req.required_shell_id = self.robot.shell_id()
     else:
         reqs = (single_robot_composite_behavior.
                 SingleRobotCompositeBehavior.role_requirements(self))
     return reqs
 def role_requirements(self):
     # forces all subbhehaviors to use the same robot
     if len(self.behaviors) > 0 and self.robot is not None:
         reqs = behavior_sequence.BehaviorSequence.role_requirements(self)
         for req in role_assignment.iterate_role_requirements_tree_leaves(
             reqs):
             req.required_shell_id = self.robot.shell_id()
     else:
         reqs = (
             single_robot_composite_behavior.SingleRobotCompositeBehavior.role_requirements(
                 self))
     return reqs
Пример #15
0
 def role_requirements(self):
     reqs = super().role_requirements()
     for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
         # Target pos is causing problems in the first few frames due to the 
         # ball velocity being completely wrong due to the ball filter. This 
         # may add some inefficiency since the closest robot to the true ball 
         # pass location is not being used.
         #if self._target_pos != None:
         #    req.destination_shape = self._target_pos
         if self.receive_point != None:
             req.destination_shape = self.receive_point
     return reqs
Пример #16
0
    def role_requirements(self):
        reqs = super().role_requirements()

        for r in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            # try to be near the ball
            if main.ball().valid:
                r.destination_shape = main.ball().pos
            if self.use_chipper:
                r.chipper_preference_weight = role_assignment.PreferChipper
            r.require_kicking = True

        return reqs
Пример #17
0
 def role_requirements(self):
     reqs = super().role_requirements()
     for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
         # Target pos is causing problems in the first few frames due to the
         # ball velocity being completely wrong due to the ball filter. This
         # may add some inefficiency since the closest robot to the true ball
         # pass location is not being used.
         #if self._target_pos != None:
         #    req.destination_shape = self._target_pos
         if self.receive_point != None:
             req.destination_shape = self.receive_point
     return reqs
    def role_requirements(self):
        if self.has_subbehaviors():
            reqs = composite_behavior.CompositeBehavior.role_requirements(self)
            if self.robot != None:
                for req in role_assignment.iterate_role_requirements_tree_leaves(
                        reqs):
                    req.previous_shell_id = self.robot.shell_id()

            return reqs
        else:
            return single_robot_behavior.SingleRobotBehavior.role_requirements(
                self)
Пример #19
0
    def role_requirements(self):
        reqs = super().role_requirements()

        # By default, single robot behaviors prefer to use the same robot.
        # Because we assign defense behaviors to handle threats somewhat
        # arbitrarily, we don't care about having the same robot, we just
        # want the closest robot to take the role.
        for subbehavior_name in ["defender1", "defender2"]:
            if subbehavior_name in reqs:
                subbehavior_req_tree = reqs[subbehavior_name]
                for r in role_assignment.iterate_role_requirements_tree_leaves(subbehavior_req_tree):
                    r.previous_shell_id = None

        return reqs
Пример #20
0
    def role_requirements(self):
        reqs = super().role_requirements()

        for r in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            # try to be near the ball
            if main.ball().valid:
                r.destination_shape = main.ball().pos
            if self.use_chipper:
                r.chipper_preference_weight = role_assignment.PreferChipper
            r.require_kicking = True

            # Increase the importance of Position to make robots closer to the ball clear it during defense
            r.position_cost_multiplier = 1.5

        return reqs
Пример #21
0
    def role_requirements(self):
        reqs = super().role_requirements()

        for r in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            # try to be near the ball
            if main.ball().valid:
                r.destination_shape = main.ball().pos
            if self.use_chipper:
                r.chipper_preference_weight = role_assignment.PreferChipper
            r.require_kicking = True

            # Increase the importance of Position to make robots closer to the ball clear it during defense
            r.position_cost_multiplier = 1.5

        return reqs
Пример #22
0
    def role_requirements(self):
        reqs = super().role_requirements()

        # By default, single robot behaviors prefer to use the same robot.
        # Because we assign defense behaviors to handle threats somewhat
        # arbitrarily, we don't care about having the same robot, we just
        # want the closest robot to take the role.
        for subbehavior_name in ['defender1', 'defender2']:
            if subbehavior_name in reqs:
                subbehavior_req_tree = reqs[subbehavior_name]
                for r in role_assignment.iterate_role_requirements_tree_leaves(
                        subbehavior_req_tree):
                    r.previous_shell_id = None

        return reqs
Пример #23
0
    def role_requirements(self):
        reqs = super().role_requirements()

        # By default, single robot behaviors prefer to use the same robot.
        # Because we assign defense behaviors to handle threats somewhat
        # arbitrarily, we don't care about having the same robot, we just want
        # the closest robot to take the role.

        # HOWEVER: Removing the bias causes flipping back and forth between
        # robots on defense occasionally, so we will only decrease the
        # robot_change_cost, not remove it.
        for subbehavior_name in ['defender1', 'defender2']:
            if subbehavior_name in reqs:
                subbehavior_req_tree = reqs[subbehavior_name]
                for r in role_assignment.iterate_role_requirements_tree_leaves(
                        subbehavior_req_tree):
                    r.robot_change_cost = DefenseOld.DEFENSE_ROBOT_CHANGE_COST

        return reqs
Пример #24
0
    def role_requirements(self):
        reqs = super().role_requirements()
        #reqs.require_kicking = True

        # try to be near the ball
        for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
            if main.ball().valid:
                # Slow ball so we can move in from any direction
                if main.ball().vel.mag(
                ) < Capture.INTERCEPT_VELOCITY_THRESH_TO_COLLECT:
                    # Get the closest robot to the ball
                    # Increase the cost significantly for robots far away so that it
                    # picks the robot already controlling the ball
                    req.destination_shape = main.ball().pos
                    req.position_cost_multiplier = Capture.POSITION_COST_MULTIPLIER
                # Fast ball, want something downfield
                else:
                    req.cost_func = Capture.role_assignment_cost
                    req.robot_change_cost = 10
                    req.destination_shape = None

        return reqs
Пример #25
0
 def role_requirements(self):
     reqs = super().role_requirements()
     for req in role_assignment.iterate_role_requirements_tree_leaves(reqs):
         #There is only one coach! Not just any robot can be coach
         req.robot_change_cost = 30.0
     return reqs