(self, motion)
Return the weight of using a motion from this node.
Return the weight of using a motion from this node.
Return the weight of using a motion from this node .
def motion_weight(self, motion):
        """Return the weight of using a motion from this node."""
        if motion != self.came_by_motion:
            # First repetition, return number of characters in the motion
            return len(motion.motion) + (
                0 if motion.argument is None else len(motion.argument)
            )
        elif self.came_by_motion_repetitions == 1:
            # Second repetition, adding a "2" is 1 extra character
            return 1
        else:
            # Difference in length of current and future count
            # 2j -> 3j = 0
            # 9j -> 10j = 1
            return len(str(self.came_by_motion_repetitions + 1)) - len(
                str(self.came_by_motion_repetitions)
            )
def motion_weight ( self , motion ) : if motion != self . came_by_motion : # First repetition, return number of characters in the motion return len ( motion . motion ) + ( 0 if motion . argument is None else len ( motion . argument ) ) elif self . came_by_motion_repetitions == 1 : # Second repetition, adding a "2" is 1 extra character return 1 else : # Difference in length of current and future count # 2j -> 3j = 0 # 9j -> 10j = 1 return len ( str ( self . came_by_motion_repetitions + 1 ) ) - len ( str ( self . came_by_motion_repetitions ) )