<commit_before>import play
import behavior
import skills.move
import skills.capture
import enum
import robocup
import role_assignment


# this test repeatedly runs the capture behavior
class TestCapture(play.Play):
    class State(enum.Enum):
        setup = 1
        capturing = 2
        rotating = 3

    def __init__(self):
        super().__init__(continuous=True)

        self.shell_id = None
        self.dribbler_power = 128
        self.face_target = robocup.Point(0,0)

        for state in TestCapture.State:
            self.add_state(state, behavior.Behavior.State.running)

        self.add_transition(behavior.Behavior.State.start,
                            TestCapture.State.setup, lambda: True,
                            'immediately')

        self.add_transition(
            TestCapture.State.setup, TestCapture.State.capturing,
            lambda: self.subbehavior_with_name('move').state == behavior.Behavior.State.completed,
            'robot away from ball')

        self.add_transition(
            TestCapture.State.capturing, TestCapture.State.rotating,
            lambda: self.subbehavior_with_name('capture').state == behavior.Behavior.State.completed,
            'rotating to check capture')

        self.add_transition(
            TestCapture.State.rotating, TestCapture.State.setup,
            lambda: self.subbehavior_with_name('aim').state == skills.aim.Aim.State.aimed,
            'successful capture')

    def on_enter_capturing(self):
        self.add_subbehavior(skills.capture.Capture(),
                             'capture',
                             required=True)

    def on_exit_capturing(self):
        self.remove_subbehavior('capture')

    def on_enter_setup(self):
        m = skills.move.Move()
        m.pos = robocup.Point(0, 1.5)
        self.add_subbehavior(m, 'move', required=True)

    def on_exit_setup(self):
        self.remove_subbehavior('move')

    def on_enter_rotating(self):
        aim = skills.aim.Aim()
        aim.target_point = self.face_target
        aim.dribbler_power = self.dribbler_power
        self.add_subbehavior(aim, 'aim', required=True)

    def on_exit_rotating(self):<commit_msg>broken: trying to add multiple rotations<commit_after>import play
import behavior
import skills.move
import skills.capture
import enum
import robocup
import role_assignment


# this test repeatedly runs the capture behavior
class TestCapture(play.Play):
    class State(enum.Enum):
        setup = 1
        capturing = 2
        rotating = 3

    def __init__(self):
        super().__init__(continuous=True)

        self.shell_id = None
        self.dribbler_power = 128
        self.face_target = robocup.Point(0,0)
        self.turn_count = 2

        for state in TestCapture.State:
            self.add_state(state, behavior.Behavior.State.running)

        self.add_transition(behavior.Behavior.State.start,
                            TestCapture.State.setup, lambda: True,
                            'immediately')

        self.add_transition(
            TestCapture.State.setup, TestCapture.State.capturing,
            lambda: self.subbehavior_with_name('move').state == behavior.Behavior.State.completed,
            'robot away from ball')

        self.add_transition(
            TestCapture.State.capturing, TestCapture.State.rotating,
            lambda: self.subbehavior_with_name('capture').state == behavior.Behavior.State.completed,
            'rotating to check capture')

        self.add_transition(
            TestCapture.State.rotating, TestCapture.State.setup,
            lambda: self.turn_count < 0,
            'successful capture')

    def on_enter_capturing(self):
        self.add_subbehavior(skills.capture.Capture(),
                             'capture',
                             required=True)

    def on_exit_capturing(self):
        self.remove_subbehavior('capture')

    def on_enter_setup(self):
        m = skills.move.Move()
        m.pos = robocup.Point(0, 1.5)
        self.add_subbehavior(m, 'move', required=True)

    def on_exit_setup(self):
        self.remove_subbehavior('move')

    def on_enter_rotating(self):
        aim = skills.aim.Aim()
        aim.target_point = self.face_target
        aim.dribbler_power = self.dribbler_power
        self.add_subbehavior(aim, 'aim', required=True)

    def execute_rotating(self):
        aim = self.subbehavior_with_name('aim')
        if self.turn_count >= 0:
            if aim.state == skills.aim.Aim.State.aimed:
                aim.target_point.rotate(aim.robot.pos, 180.0)
                self.turn_count -= 1

    def on_exit_rotating(self):
        self.turn_count = 2
{'fraction_non_alphanumeric': 0.09606332905434317, 'fraction_numerical': 0.006632434745400086, 'mean_word_length': 2.2738095238095237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5822105', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1314, 'n_words': 248}