How to use the rlbot.utils.game_state_util.GameState function in rlbot

To help you get started, we’ve selected a few rlbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SaltieRL / Saltie / agents / self_evolving_car / self_evolving_car_agent.py View on Github external
# RENDER RESULTS
        self.renderer.begin_rendering()
        message = "GEN: " + str(self.gen + 1) + " | BOT: " + str(self.brain)
        self.renderer.draw_string_2d(10, 10, 3, 3, message, self.renderer.white())
        self.renderer.end_rendering()

        # END GENERATION
        if packet.game_ball.latest_touch.player_name == "Self-Evolving-Car":
            self.mutRate = 0

        # GAME STATE
        car_state = CarState(boost_amount=100)
        ball_state = BallState(
            Physics(velocity=Vector3(0, 0, 0), location=Vector3(0, -1000, 1200), angular_velocity=Vector3(0, 0, 0)))
        game_state = GameState(ball=ball_state, cars={self.index: car_state})
        self.set_game_state(game_state)

        # KILL
        if (my_car.physics.location.z < 100 or my_car.physics.location.z > 1950 or my_car.physics.location.x < -4000
            or my_car.physics.location.x > 4000 or my_car.physics.location.y > 5000) and self.frame > 50:
            self.frame = 5000

        return self.controller_state
github SaltieRL / Saltie / agents / self_evolving_car / self_evolving_car_agent.py View on Github external
def reset(self):
        # RESET TRAINING ATTRIBUTES AFTER EACH GENOME
        ball_state = BallState(Physics(velocity=Vector3(0, 0, 0), location=Vector3(self.pos, 5000, 3000),
                                       angular_velocity=Vector3(0, 0, 0)))
        car_state = CarState(jumped=False, double_jumped=False, boost_amount=33,
                             physics=Physics(velocity=Vector3(0, 0, 0), rotation=Rotator(45, 90, 0),
                                             location=Vector3(0.0, -4608, 500), angular_velocity=Vector3(0, 0, 0)))
        game_info_state = GameInfoState(game_speed=1)
        game_state = GameState(ball=ball_state, cars={self.index: car_state}, game_info=game_info_state)
        self.set_game_state(game_state)
github Darxeal / BotimusPrime / training / botimus_training.py View on Github external
def make_game_state(self, rng: SeededRandomNumberGenerator):
        self.rng = rng
        ball = Ball()
        car = Car()
        self.set_car_ball_state(car, ball)
        return GameState(
            ball=BallState(
                physics=Physics(
                    location=vec3_to_Vector3(ball.position),
                    velocity=vec3_to_Vector3(ball.velocity),
                    angular_velocity=vec3_to_Vector3(ball.angular_velocity)
                )
            ),
            cars={
                0: CarState(
                    physics=Physics(
                        location=vec3_to_Vector3(car.position),
                        velocity=vec3_to_Vector3(car.velocity),
                        angular_velocity=vec3_to_Vector3(car.angular_velocity),
                        rotation=mat3_to_Rotator(car.orientation)
                    ),
                    boost_amount=car.boost
github SaltieRL / Saltie / agents / self_evolving_car / train.py View on Github external
self.distance_to_ball[self.frame] = math.sqrt(
            distance_to_ball_x ** 2 + distance_to_ball_y ** 2 + distance_to_ball_z ** 2)

        # render results
        action_display = "GEN: " + str(self.gen + 1) + " | BOT: " + str(self.brain)
        draw_debug(self.renderer, action_display)

        # stop evolving when ball is touched
        # if packet.game_ball.latest_touch.player_name == "Self-Evolving-Car":
        #  self.mut_rate = 0

        # game state
        car_state = CarState(boost_amount=100)
        ball_state = BallState(Physics(velocity=Vector3(0, 0, 0), location=Vector3(0, -1000, 1200),
                                       angular_velocity=Vector3(0, 0, 0)))
        game_state = GameState(ball=ball_state, cars={self.index: car_state})
        self.set_game_state(game_state)

        # neural net outputs
        with self.torch.no_grad():
            outputs = self.bot_list[self.brain].forward(*inputs)
        self.controller_state = self.output_formatter.format_model_output(outputs, [packet])[0]

        # kill
        if (my_car.physics.location.z < 100 or my_car.physics.location.z > 1950
            or my_car.physics.location.x < -4000 or my_car.physics.location.x > 4000
            or my_car.physics.location.y > 5000 or my_car.physics.location.y < -5000) \
                and self.frame > 50:
            self.frame = self.max_frames

        # loops
        self.frame = self.frame + 1
github Darxeal / BotimusPrime / tools / state_setting.py View on Github external
def execute(self):
        if self._changed:
            self.agent.set_game_state(GameState(
                ball=self.ball,
                cars={self.agent.index: self.car},
                game_info=self.gameinfo
            ))
            self.begin()
github SaltieRL / Saltie / agents / self_evolving_car / train.py View on Github external
def reset(self):
        """Resets game data after each genome"""
        ball_state = BallState(Physics(velocity=Vector3(0, 0, 0), location=Vector3(self.pos, 5000, 3000),
                                       angular_velocity=Vector3(0, 0, 0)))
        car_state = CarState(jumped=False, double_jumped=False, boost_amount=33,
                             physics=Physics(velocity=Vector3(0, 0, 0), rotation=Rotator(45, 90, 0),
                                             location=Vector3(0.0, -4608, 500), angular_velocity=Vector3(0, 0, 0)))
        game_info_state = GameInfoState(game_speed=1)
        game_state = GameState(ball=ball_state, cars={self.index: car_state}, game_info=game_info_state)
        self.set_game_state(game_state)
github samuelpmish / ExampleBots / 2_Aerial_Recovery / agent.py View on Github external
rotation = Rotator(random.uniform(-1.5, 1.5),
                               random.uniform(-1.5, 1.5),
                               random.uniform(-1.5, 1.5))

            angular_velocity = Vector3(random.uniform(-3.0, 3.0),
                                       random.uniform(-3.0, 3.0),
                                       random.uniform(-3.0, 3.0))

            car_state = CarState(physics=Physics(
                location=position,
                velocity=velocity,
                rotation=rotation,
                angular_velocity=angular_velocity
            ))

            self.set_game_state(GameState(cars={self.index: car_state}))

        if self.timer > 0.10:

            if self.action == None:
                self.action = AerialTurn(self.info.my_car)

            self.renderer.begin_rendering()
            red = self.renderer.create_color(255, 255, 30, 30)
            self.renderer.draw_polyline_3d(self.action.trajectory, red)
            self.renderer.end_rendering()


            self.action.step(1.0 / 60.0)
            self.controls = self.action.controls

            self.timer += 1.0 / 60.0