Beispiel #1
0
    def test_initially_moving_to_middle(self):
        zone = self.world_left.pitch.zones[2][0]

        target_x, target_y = self.strategy_left._get_shooting_coordinates(
            self.world_left.our_attacker)

        for x, y in zone:
            robot = self.get_aimed_robot(
                x, y, target_x, target_y, self.world_left.our_attacker.zone)
            world = World('left')
            self.place_robot(world, world.our_attacker.zone, robot)

            strategy = AttackerScoreDynamic(world)

            actions = strategy.generate()
            left_motor = actions['left_motor']
            right_motor = actions['right_motor']

            # Both left motor and right motor should be positive or negative.
            self.assertEqual(True, left_motor * right_motor > 0)
Beispiel #2
0
    def test_confuse1_rotation_up(self):
        target_x, target_y = self.strategy_left.shooting_pos

        aim_x = self.world_left.their_goal.x
        aim_y = self.world_left.their_goal.y + self.world_left.their_goal.height / 2 + self.strategy_left.GOAL_CORNER_OFFSET

        attacker = self.get_aimed_robot(
            target_x, target_y, aim_x, aim_y,
            self.world_left.our_attacker.zone)

        defender = self.get_aimed_robot(
            self.world_left.their_goal.x, self.world_left.their_goal.y,
            aim_x, aim_y, self.world_left.their_defender.zone)

        world = World('left')
        self.place_robot(world, attacker.zone, attacker)
        self.place_robot(world, defender.zone, defender)

        strategy = AttackerScoreDynamic(world)

        actions = strategy.generate()
        self.assertTrue(actions['left_motor'] < 0)
        self.assertTrue(actions['right_motor'] > 0)
Beispiel #3
0
 def setUp(self):
     self.world_left = World('left')
     self.strategy_left = AttackerScoreDynamic(self.world_left)
     self.world_right = World('right')
     self.strategy_right = AttackerScoreDynamic(self.world_right)
Beispiel #4
0
 def setUp(self):
     self.world_left = World('left')
     self.strategy_left = DefaultDefenderDefence(self.world_left)