Skip to content

VirxEC/rl_ball_sym_pybinds

Repository files navigation

RLBot Python bindings for rl_ball_sym

forthebadge

Pre-built binaries for Python 3.10 and beyond in Windows & Linux can be found here in the build artifacts for the latest workflow run.

Prerequisites

  • Rust & Cargo
  • RLBot - Verify that the file %localappdata%\RLBotGUIX\Python311\python.exe exists. If it doesn't, please re-download and re-install from the website to update.
  • Maturin - Downloaded onto your main global Python installation, you can install via pip install maturin

Steps to build the Python bindings

  1. Download this repository
  2. Run develop.bat
  3. The package will be automatically installed into RLBot's Python installation
  4. import rl_ball_sym_pybinds in your Python file

Basic usage in an RLBot script to render the path prediction

See script.cfg and script.py for a pre-made script that renders the framework's ball path prediction in green and the rl_ball_sym's ball path prediction in red.

from traceback import print_exc

from rlbot.agents.base_script import BaseScript
from rlbot.utils.structures.game_data_struct import GameTickPacket

import rl_ball_sym_pybinds as rlbs


class rl_ball_sym(BaseScript):
    def __init__(self):
        super().__init__("rl_ball_sym")

    def main(self):
        rlbs.load_standard()

        while 1:
            try:
                self.packet: GameTickPacket = self.wait_game_tick_packet()
                rlbs.tick(self.packet)
                path_prediction = rlbs.get_ball_prediction_struct()

                self.renderer.begin_rendering()
                self.renderer.draw_polyline_3d(tuple(path_prediction.slices[i].location for i in range(0, path_prediction.num_slices)), self.renderer.red())
                self.renderer.end_rendering()
            except Exception:
                print_exc()


if __name__ == "__main__":
    rl_ball_sym = rl_ball_sym()
    rl_ball_sym.main()

Documentation

For documentation, see rl_ball_sym_pybinds.pyi.

Benchmarks

Results of pytest.py:

get_ball_prediction_struct takes 0.08ms to execute in soccer