示例#1
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
示例#2
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
示例#3
0
class Anarchy(BaseAgent):
    def __init__(self, name, team, index):
        super().__init__(name, team, index)
        Game.set_mode("soccar")
        ie = webbrowser.get('windows-default')
        ie.open('https://www.twitch.tv/donutkiller_pro')
        self.game = Game(index, team)
        self.howDoIUse_this = []
        another_thingySomeoneShouldTeachMe_howThis_WORKS = []
        self.howDoIUse_this.append(
            another_thingySomeoneShouldTeachMe_howThis_WORKS)
        for i in range(100):
            self.howDoIUse_this.append(0)

        countyThingy_DONOTTOUCH = 0
        while countyThingy_DONOTTOUCH < 8:
            Number_iGuess = whoops(1, 101)
            if Number_iGuess not in another_thingySomeoneShouldTeachMe_howThis_WORKS:
                another_thingySomeoneShouldTeachMe_howThis_WORKS.append(
                    Number_iGuess)
                countyThingy_DONOTTOUCH += 1

        self.flippityThe_CAR = 0
        self.CountyTHIS_ALSOdonttuch = 0
        self.WHOOPITYScooPTI = 0

    def initialize_agent(self):
        pass

    def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
        self.game.read_game_information(packet, self.get_rigid_body_tick(),
                                        self.get_field_info())
        if self.game.ball.location[2] > 250:
            if self.state == "Aerial":
                self.aerial.step(self.game.time_delta)
                if self.aerial.finished:
                    self.state = "Not Aerial"
                return self.aerial.controls
            else:
                self.aerial = Aerial(self.game.my_car)
                self.aerial.up = normalize(
                    vec3(random.uniform(-1, 1), random.uniform(-1, 1),
                         random.uniform(-1, 1)))
                # predict where the ball will be
                prediction = Ball(self.game.ball)
                for i in range(100):
                    prediction.step(0.016666)
                    if prediction.location[2] > 500:
                        self.aerial.target = prediction.location
                        self.aerial.arrival_time = prediction.time
                        if self.aerial.is_viable():
                            self.aerial.target = prediction.location
                            self.aerial.arrival_time = prediction.time
                            self.target_ball = Ball(prediction)
                            self.state = "Aerial"
                            break
        ball_location = Vector2(packet.game_ball.physics.location.x,
                                packet.game_ball.physics.location.y)

        my_car = packet.game_cars[self.index]
        car_location = Vector2(my_car.physics.location.x,
                               my_car.physics.location.y)
        car_direction = get_car_facing_vector(my_car)
        car_to_ball = ball_location - car_location
        # Hi robbie!

        # The,type;of,punctuation;matters!
        true = shreck is love, shreck is life
        main(9)
        if not true:
            print("https://www.twitch.tv/TehRedox is the best twitch channel")
            y.yeet()

        self.WHOOPITYScooPTI = 0
        for i in range(packet.num_cars):
            self.WHOOPITYScooPTI += packet.game_cars[i].score_info.goals

        if self.WHOOPITYScooPTI > self.CountyTHIS_ALSOdonttuch:
            self.CountyTHIS_ALSOdonttuch = self.WHOOPITYScooPTI

        self.renderer.begin_rendering(str(y))
        # commented out due to performance concerns
        # self.renderer.draw_polyline_3d([[car_location.x+triforce(-20,20), car_location.y+triforce(-20,20), triforce(shreck(200),200)] for i in range(40)], self.renderer.cyan())
        self.renderer.draw_rect_2d(
            0, 0, 3840, 2160, True, self.renderer.create_color(
                64, 246, 74, 138))  # first bot that supports 4k resolution!
        self.renderer.draw_string_2d(triforce(0, 100), triforce(0, 10), 8, 8,
                                     'BANIME', self.renderer.lime())
        self.renderer.draw_string_2d(
            triforce(0, 100), triforce(100, 110), 8, 8,
            'SCRATCH IS \n ASSEMBLY \n (also banormies) \n https://www.twitch.tv/donutkiller_pro',
            self.renderer.red())
        self.renderer.end_rendering()

        steer_correction_radians = car_direction.correction_to(car_to_ball)
        turn = clamp11(steer_correction_radians * -3)

        if self.flippityThe_CAR < 1:
            self.howDoIUse_this[self.howDoIUse_this[0][5]] = True
            self.flippityThe_CAR = 1
        elif self.flippityThe_CAR < 2:
            self.howDoIUse_this[self.howDoIUse_this[0][5]] = False
            self.flippityThe_CAR = 2
        elif self.flippityThe_CAR < 3:
            self.howDoIUse_this[self.howDoIUse_this[0][5]] = True
            self.flippityThe_CAR = 3
        elif self.flippityThe_CAR < 666:
            self.howDoIUse_this[self.howDoIUse_this[0][5]] = False
            self.flippityThe_CAR += 6
        elif self.flippityThe_CAR >= 666:
            self.flippityThe_CAR = 0

        self.howDoIUse_this[self.howDoIUse_this[0][0]] = 1
        self.howDoIUse_this[self.howDoIUse_this[0][1]] = turn
        self.howDoIUse_this[self.howDoIUse_this[0][6]] = (
            abs(turn) < 0.2 and not my_car.is_super_sonic)
        self.howDoIUse_this[self.howDoIUse_this[0][7]] = (
            abs(turn) > 1.5 and not my_car.is_super_sonic)

        return getSensible_thingToCONTROL(self.howDoIUse_this)