Exemplo n.º 1
0
 def execute(self):
     # print(self.car)
     self.substate = substates.pick_state(self, self.agent, self.car,
                                          self.ball.location, 2400,
                                          self.hierarchy)
     self.expired = True
     return self.substate.step(1.0 / 60.0)
Exemplo n.º 2
0
    def execute(self):

        car_state = CarState(jumped=False,
                             double_jumped=False,
                             boost_amount=87,
                             physics=Physics(location=rlv3(-1000, -2000, 20),
                                             velocity=rlv3(0, 0, 0),
                                             rotation=rlv3(0, -1, 0),
                                             angular_velocity=rlv3(0, 0, 0)))

        ball_state = BallState(
            Physics(location=rlv3(1000, 1100, 100),
                    velocity=rlv3(0, 0, 0),
                    rotation=rlv3(0, 0, 0),
                    angular_velocity=rlv3(0, 0, 0)))

        game_state = GameState(ball=ball_state,
                               cars={self.agent.index: car_state})

        self.agent.set_game_state(game_state)
        self.expired = True

        r = 1000
        x = [r / 2, -r, -r, r, r, -r / 2]
        y = [-r / 2, -r, r, r, -r, -r / 2]
        nodes = np.asfortranarray([x, y])
        curve = structs.test(nodes, bezier.Curve.from_nodes(nodes))

        self.agent.renderer.draw_polyline_3d(curve.get_path_points(),
                                             self.agent.renderer.blue())

        self.substate = substates.pick_state(
            self, self.agent, self.car, self.ball.location, 2300,
            self.hierarchy)  # Drive(self.car, target, 2000)
        return self.substate.step(1.0 / 60.0)
Exemplo n.º 3
0
    def execute(self):
        self.expired = self.available()

        target = self.ball
        angle_to_target = utils.angle2D(target.location, self.car)

        closest = target
        for boost in self.agent.game_info.boosts:
            if utils.distance2D(target.location,
                                self.car.location) < utils.distance2D(
                                    boost.location, target.location):
                continue

            angle_to_boost = utils.angle2D(boost.location, self.car)
            angle_dif = angle_to_target - angle_to_boost

            if abs(angle_dif) < math.radians(15):
                if utils.distance2D(closest.location,
                                    self.car.location) > utils.distance2D(
                                        boost.location, self.car.location):
                    closest = boost

        target = closest.location
        self.substate = substates.pick_state(
            self, self.agent, self.car, target, 2300,
            self.hierarchy)  # Drive(self.car, target, 2000)

        return self.substate.step(1.0 / 60.0)
Exemplo n.º 4
0
    def execute(self):
        #getting the coordinates of the goalposts
        target_location = self.ball.location
        leftPost = self.agent.game_info.their_goal.left_post
        rightPost = self.agent.game_info.their_goal.right_post
        center = self.agent.game_info.their_goal.location

        self.substate = substates.pick_state(self, self.agent, self.car,
                                             target_location, 2400,
                                             self.hierarchy)
        if utils.ballReady(self) == False or abs(self.ball.location.y) > 5050:
            self.expired = True
        return self.substate.step(1.0 / 60.0)
Exemplo n.º 5
0
    def execute(self):
        target = self.agent.game_info.my_goal.location
        speed = 2400

        if utils.distance2D(self.car.location,
                            target) < 1000 or utils.distance2D(
                                self.ball.location, target) > utils.distance2D(
                                    self.car.location, target):
            self.expired = True

        self.substate = substates.pick_state(
            self, self.agent, self.car, target, speed,
            self.hierarchy)  # Drive(self.car, target, 2000)
        return self.substate.step(1.0 / 60.0)
Exemplo n.º 6
0
    def execute(self):
        goal = self.agent.game_info.my_goal.location

        target = utils.find_point_on_line(goal, self.ball.location, 1 / 3)
        speed = 2400

        if utils.distance2D(self.ball.location, goal) > utils.distance2D(
                self.car.location, goal) + utils.turn_radius(self.car) * 1.5:
            self.expired = True

        self.substate = substates.pick_state(
            self, self.agent, self.car, target, speed,
            self.hierarchy)  # Drive(self.car, target, 2000)
        return self.substate.step(1.0 / 60.0)
Exemplo n.º 7
0
    def execute(self):
        target = self.ball.location
        offset = (target.x / utils.FIELD_WIDTH) * math.pi
        x = target.x + 90 * abs(math.cos(offset)) * utils.sign(offset)
        y = target.y + 90 * abs(math.sin(offset)) * utils.sign(self.agent.team)
        # target = Vector3(x,y,target.z)

        self.substate = substates.pick_state(self, self.agent, self.car,
                                             target, 2400, self.hierarchy)
        self.expired = (
            not utils.ballProject(self) >
            -(utils.distance2D(self.ball.location, self.car.location) / 2)
            or (calcShoot(self.agent).available()))
        return self.substate.step(1.0 / 60.0)