Ejemplo n.º 1
0
class TurnAndDriveToBall(TrainingExercise):
    steering_coefficient: float = 5

    grader: Grader = field(default_factory=lambda: GameTickPacketWrapperGrader(
        StrikerGrader(timeout_seconds=4.0, ally_team=0)))

    match_config: MatchConfig = field(
        default_factory=lambda: make_match_config_with_bots(
            blue_bots=[BotConfigs.tweaked_bot]))

    def on_briefing(self) -> Optional[Grade]:
        _ = send_and_wait_for_replies(self.get_matchcomms(), [
            make_set_attributes_message(
                0, {'steering_coefficient': self.steering_coefficient}),
        ])

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(physics=Physics(location=Vector3(0, 5100, 100),
                                           velocity=Vector3(0, 0, 0),
                                           angular_velocity=Vector3(0, 0, 0))),
            cars={
                0:
                CarState(physics=Physics(location=Vector3(0, 3400, 0),
                                         rotation=Rotator(0, 0, 0),
                                         velocity=Vector3(0, 0, 0),
                                         angular_velocity=Vector3(0, 0, 0)),
                         jumped=False,
                         double_jumped=False,
                         boost_amount=0)
            },
            boosts={i: BoostState(0)
                    for i in range(34)},
        )
Ejemplo n.º 2
0
class FarAwayBall(TrainingExercise):
    grader: Grader = field(default_factory=lambda: GameTickPacketWrapperGrader(
        StrikerGrader(timeout_seconds=7.0, ally_team=0)))
    car_x: float = 1000
    car_y: float = -4608
    car_z: float = 17
    car_vx: float = 0
    car_vy: float = 0
    car_spin: float = pi / 2
    boost: float = 33

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(physics=Physics(
                location=Vector3(0, 4500, 100),
                velocity=Vector3(0, 0, 0),
                angular_velocity=Vector3(0, 0, 0))),
            cars={
                0: CarState(
                    physics=Physics(
                        location=Vector3(self.car_x, self.car_y, self.car_z),
                        rotation=Rotator(0, self.car_spin, 0),
                        velocity=Vector3(self.car_vx, self.car_vy, 0),
                        angular_velocity=Vector3(0, 0, 0)),
                    jumped=False,
                    double_jumped=False,
                    boost_amount=self.boost)
            },
            boosts={1: BoostState(100)},
        )
Ejemplo n.º 3
0
class KickOff1v1(TrainingExercise):
    grader: Grader = field(default_factory=lambda: GameTickPacketWrapperGrader(
        StrikerGrader(timeout_seconds=8, ally_team=0)))
    car_start_x: float = 0
    car_start_y: float = 0
    car_yaw: float = 0

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(physics=Physics(location=Vector3(0, 0, 100),
                                           velocity=Vector3(0, 0, 0),
                                           angular_velocity=Vector3(0, 0, 0))),
            cars={
                0:
                CarState(physics=Physics(location=Vector3(
                    self.car_start_x, self.car_start_y, 16.5),
                                         rotation=Rotator(0, self.car_yaw, 0),
                                         velocity=Vector3(0, 0, 0),
                                         angular_velocity=Vector3(0, 0, 0)),
                         boost_amount=33),
                1:
                CarState(physics=Physics(location=Vector3(
                    -self.car_start_x, -self.car_start_y, 16.5),
                                         rotation=Rotator(0, -self.car_yaw, 0),
                                         velocity=Vector3(0, 0, 0),
                                         angular_velocity=Vector3(0, 0, 0)),
                         boost_amount=33)
            },
        )
Ejemplo n.º 4
0
class StationaryBall(TrainingExercise):
    grader: Grader = field(default_factory=lambda: GameTickPacketWrapperGrader(
        StrikerGrader(timeout_seconds=8.0, ally_team=0)))
    ball_start_x: float = 0
    ball_start_y: float = -3000
    ball_start_z: float = 120
    car_start_x: float = 1000
    car_start_y: float = -4000
    car_angle: float = pi / 2


    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(physics=Physics(
                location=Vector3(self.ball_start_x + rng.uniform(-30, 30), self.ball_start_y, self.ball_start_z),
                velocity=Vector3(0, 0, 0),
                angular_velocity=Vector3(0, 0, 0))),
            cars={
                0: CarState(
                    physics=Physics(
                        location=Vector3(self.car_start_x, self.car_start_y, 0),
                        rotation=Rotator(0, self.car_angle, 0),
                        velocity=Vector3(0, 0, 0),
                        angular_velocity=Vector3(0, 0, 0)),
                    jumped=False,
                    double_jumped=False,
                    boost_amount=100)
            },
            boosts={1: BoostState(100)},
        )
Ejemplo n.º 5
0
 def __init__(self,
              ball_physics: Dict[str, Any],
              cars: List[Dict[str, Any]],
              boosts: Optional[List[Union[str, int]]] = None,
              timeout: Optional[float] = None,
              description: Optional[str] = None):
     self.description = description or "Striker Exercise"
     self.ball = ball_physics
     self.cars = cars
     self.boosts = boosts or []
     self.timeout = timeout or 10.0
     self.grader = StrikerGrader(
         self.timeout) if self.timeout > 0 else PassOnGoalForAllyTeam(0)
     JSONExercise.__init__(self)
Ejemplo n.º 6
0
class Setup(TrainingExercise):
    grader: Grader = field(default_factory=lambda: GameTickPacketWrapperGrader(
        StrikerGrader(timeout_seconds=10.0, ally_team=0)))
    ball_x: float = 0
    ball_y: float = 0
    ball_z: float = 0
    ball_vx: float = 0
    ball_vy: float = 0
    ball_vz: float = 0
    ball_sx: float = 0
    ball_sy: float = 0
    ball_sz: float = 0

    car_x: float = 0
    car_y: float = -4000
    car_z: float = 20
    car_spin: float = pi / 2
    boost: float = 50
    minboost: float = None
    maxboost: float = None

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        minboost = self.boost if self.minboost is None else self.minboost
        maxboost = self.boost if self.maxboost is None else self.maxboost

        return GameState(
            ball=BallState(physics=Physics(
                location=Vector3(self.ball_x, self.ball_y, self.ball_z),
                velocity=Vector3(self.ball_vx, self.ball_vy, self.ball_vz),
                angular_velocity=Vector3(self.ball_sx, self.ball_sy,
                                         self.ball_sz))),
            cars={
                0:
                CarState(physics=Physics(location=Vector3(
                    self.car_x, self.car_y, self.car_z),
                                         rotation=Rotator(0, self.car_spin, 0),
                                         velocity=Vector3(0, 0, 0),
                                         angular_velocity=Vector3(0, 0, 0)),
                         jumped=False,
                         double_jumped=False,
                         boost_amount=rng.uniform(minboost, maxboost))
            },
            boosts={i: BoostState(0)
                    for i in range(34)},  # Is this needed.
        )
Ejemplo n.º 7
0
class VersusLineGoalie(TrainingExercise):

    match_config: MatchConfig = field(
        default_factory=lambda: versus_line_goalie_match_config(
            attacker=BotConfigs.simple_bot))

    grader: StrikerGrader = field(default_factory=lambda: StrikerGrader(
        timeout_seconds=7, ally_team=striker_team))

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(
                physics=Physics(location=Vector3(0, -1500, 100),
                                velocity=Vector3(rng.uniform(-1, 1), 10, 0),
                                angular_velocity=Vector3(0, 0, 0))),
            cars={
                # Striker
                0:
                CarState(
                    physics=Physics(location=Vector3(300 * rng.n11(),
                                                     200 * rng.n11(), 15),
                                    rotation=Rotator(0, -pi / 2, 0),
                                    velocity=Vector3(0, 0, 0),
                                    angular_velocity=Vector3(0, 0, 0)),
                    # jumped=False,
                    # double_jumped=False,
                    boost_amount=100),
                # Goalie
                1:
                CarState(
                    physics=Physics(location=Vector3(0, -5000, 15),
                                    rotation=Rotator(0, rng.uniform(-.1, .1),
                                                     0),
                                    velocity=Vector3(0, 0, 0),
                                    angular_velocity=Vector3(0, 0, 0)),
                    # jumped=True,
                    # double_jumped=True,
                    boost_amount=100),
            },
            boosts={i: BoostState(0)
                    for i in range(34)},
        )
Ejemplo n.º 8
0
class WideRollingTowardsGoalShot(StrikerExercise):
    grader: StrikerGrader = field(
        default_factory=lambda: StrikerGrader(timeout_seconds=6.))

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(ball=BallState(
            Physics(location=Vector3(rng.uniform(900, 1300),
                                     rng.uniform(0, 1500), 100),
                    velocity=Vector3(0, 550, 0))),
                         cars={
                             0:
                             CarState(boost_amount=87,
                                      jumped=True,
                                      double_jumped=True,
                                      physics=Physics(
                                          location=Vector3(2000, -2500, 25),
                                          rotation=Rotator(0, pi / 2, 0),
                                          velocity=Vector3(0, 0, 0),
                                          angular_velocity=Vector3(0, 0, 0),
                                      ))
                         })
Ejemplo n.º 9
0
class Strike(TrainingExercise):
    grader: Grader = field(
        default_factory=lambda: StrikerGrader(timeout_seconds=4))
    ball_x: float = 0
    ball_y: float = 10
    ball_z: float = 150
    ball_vx: float = 0
    ball_vy: float = 0
    ball_vz: float = 0
    ball_sx: float = 0
    ball_sy: float = 0
    ball_sz: float = 0.1

    car_x: float = 0
    car_y: float = 10
    car_z: float = 17
    car_spin: float = 0
    car_pitch: float = 0
    car_roll: float = 0

    def make_game_state(self, rng: SeededRandomNumberGenerator) -> GameState:
        return GameState(
            ball=BallState(physics=Physics(
                location=Vector3(self.ball_x, self.ball_y, self.ball_z),
                velocity=Vector3(self.ball_vx, self.ball_vy, self.ball_vz),
                angular_velocity=Vector3(self.ball_sx, self.ball_sy,
                                         self.ball_sz))),
            cars={
                0:
                CarState(physics=Physics(
                    location=Vector3(self.car_x, self.car_y, self.car_z),
                    rotation=Rotator(self.car_pitch, self.car_spin,
                                     self.car_roll),
                    velocity=Vector3(0, 0, 0),
                    angular_velocity=Vector3(0, 0, 0)),
                         boost_amount=100)
            },
            boosts={i: BoostState(0)
                    for i in range(34)},  # Is this needed.
        )
Ejemplo n.º 10
0
def make_recovery_grader():
    return StrikerGrader(timeout_seconds=4)
Ejemplo n.º 11
0
def make_striker_grader():
    return StrikerGrader(timeout_seconds=8)
Ejemplo n.º 12
0
 def __init__(self, shot_id: str):
     self.shot_json = self._get_shot_json(shot_id)
     super().__init__(
         name=self.shot_json['name'],
         grader=StrikerGrader()
     )