Exemple #1
0
def rendezvous_prediction(game_info, min_time, persistent):
    '''
    Updates the place and time we will be contacting the ball
    '''

    prediction = game_info.ball_prediction

    for i in range(0, len(prediction.slices), 2):

        aerial = Aerial(game_info.utils_game.my_car)

        #if prediction.slices[i].pos.z > 150:# and prediction.slices[i].time > min_time:
        aerial.target = Vec3_to_vec3(prediction.slices[i].pos,
                                     game_info.team_sign)
        aerial.arrival_time = prediction.slices[i].time
        simulation = aerial.simulate()
        if (vec3_to_Vec3(simulation.location, game_info.team_sign) -
                vec3_to_Vec3(aerial.target,
                             game_info.team_sign)).magnitude() < 30:
            persistent.aerial.target_location = prediction.slices[i].pos
            persistent.aerial.target_time = prediction.slices[i].time
            break

        #else:
        ''' This currently isn't defined, so we're going to skip it for now.
        if prediction.time - game_info.game_time > drive_time(game_info,
        prediction.location,
        game_info.me.boost):
        persistent.hit_ball.action.target = prediction.location
        persistent.hit_ball.action.arrival_time = prediction.time
        break
        '''

    return persistent
Exemple #2
0
    def __init__(self, car: Car, ball_predictions, predicate: callable = None):
        self.ball: Ball = None
        self.is_viable = True

        #find the first reachable ball slice that also meets the predicate
        test_car = Car(car)
        test_aerial = Aerial(car)
        
        for ball in ball_predictions:
            test_aerial.target = ball.position
            test_aerial.arrival_time = ball.time

            # fake our car state :D
            dir_to_target = ground_direction(test_car.position, test_aerial.target)
            test_car.velocity = dir_to_target * max(norm(test_car.velocity), 1200)
            test_car.orientation = look_at(dir_to_target, vec3(0,0,1))

            if test_aerial.is_viable() and (predicate is None or predicate(car, ball)):
                self.ball = ball
                break

        #if no slice is found, use the last one
        if self.ball is None:
            self.ball = ball_predictions[-1]
            self.is_viable = False

        self.time = self.ball.time
        self.ground_pos = ground(self.ball.position)
        self.position = self.ball.position
Exemple #3
0
    def __init__(self, car: Car, ball_predictions: List[Ball]):
        self.car: Car = car
        self.ball: Ball = None
        self.is_viable = True

        test_aerial = Aerial(car)
        for i in range(0, len(ball_predictions)):
            ball_slice = ball_predictions[i]
            test_aerial.target = ball_slice.position
            test_aerial.arrival_time = ball_slice.time
            if test_aerial.is_viable():
                self.ball = ball_slice
                break

        # if no slice is found, use the last one
        if self.ball is None:
            if not ball_predictions:
                self.ball = Ball()
                self.ball.time = math.inf
            else:
                self.ball = ball_predictions[-1]
            self.is_viable = False

        self.time = self.ball.time
        self.position = self.ball.position
Exemple #4
0
def copy_aerial(aerial: Aerial, car: Car):
    aerial_copy = Aerial(car)
    aerial_copy.target = vec3(aerial.target)
    aerial_copy.arrival_time = aerial.arrival_time
    aerial_copy.target_orientation = aerial.target_orientation
    aerial_copy.up = aerial.up
    aerial_copy.angle_threshold = aerial.angle_threshold
    aerial_copy.reorient_distance = aerial.reorient_distance
    aerial_copy.throttle_distance = aerial.throttle_distance
    return aerial_copy
    def simulate_flight(car: Car, aerial: Aerial, flight_path: List[vec3] = None) -> Car:
        test_car = Car(car)
        test_aerial = Aerial(test_car)
        test_aerial.target = aerial.target
        test_aerial.arrival_time = aerial.arrival_time
        test_aerial.angle_threshold = aerial.angle_threshold
        test_aerial.up = aerial.up
        test_aerial.single_jump = aerial.single_jump

        if flight_path: flight_path.clear()

        while not test_aerial.finished:
            test_aerial.step(1 / 120)
            test_car.boost = 100  # TODO: fix boost depletion in RLU car sim
            test_car.step(test_aerial.controls, 1 / 120)

            if flight_path:
                flight_path.append(vec3(test_car.position))

        return test_car
Exemple #6
0
    def simulate_flight(self, car: Car, write_to_flight_path=True) -> Car:
        test_car = Car(car)
        test_aerial = Aerial(test_car)
        test_aerial.target = self.aerial.target
        test_aerial.arrival_time = self.aerial.arrival_time
        test_aerial.angle_threshold = self.aerial.angle_threshold
        test_aerial.up = self.aerial.up
        test_aerial.single_jump = self.aerial.single_jump

        if write_to_flight_path:
            self._flight_path.clear()

        while not test_aerial.finished:
            test_aerial.step(1 / 120)
            test_car.boost = 100  # TODO: fix boost depletion in RLU car sim
            test_car.step(test_aerial.controls, 1 / 120)

            if write_to_flight_path:
                self._flight_path.append(vec3(test_car.position))

        return test_car
Exemple #7
0
def choose_stationary_takeoff_time(game_info, target_loc, target_time):
    '''
    Decides when to take off for an aerial based on a given target time and place.
    Assumes we're sitting still to start with.
    '''

    aerial = Aerial(game_info.utils_game.my_car)

    aerial.target = Vec3_to_vec3(target_loc, game_info.team_sign)
    current_time = game_info.game_time
    test_interval = [current_time, target_time]
    while abs(test_interval[1] - test_interval[0]) > 1 / 30:
        test_time = (test_interval[0] + test_interval[1]) / 2
        aerial.arrival_time = test_time
        simulation = aerial.simulate()
        if vec3_to_Vec3(simulation.location - aerial.target,
                        game_info.team_sign).magnitude() < 100:
            test_interval = [test_interval[0], test_time]
        else:
            test_interval = [test_time, test_interval[1]]
    return target_time - (test_interval[1] - current_time)