Crate rlbot

source ·
Expand description

crates.io docs Build Status

RLBot is a framework for creating offline Rocket League bots. This crate lets you write bots using a simple, safe interface that should feel comfortable to Rust developers.

Most types in this crate are exported directly from RLBot, so for anything not documented here, you’ll need to use RLBot’s docs as the authoritative reference.

There are two ways to use this crate:

  1. run_bot and Bot – This is the high-level interface. It plays a single match from start to finish. It expects the app to have been launched by the RLBot framework, and runs its own game loop under framework control.
  2. init and RLBot – This is the low-level interface. You can use this to directly access the innards of RLBot for scripting, integration tests, or any other custom use-case.

Examples

This crate comes with plenty examples to get you started. All the examples can be run directly from the repo. For example, to run the simple example, run this command:

cargo run --example simple

examples/simple (Source)

This is a simple ATBA, or Always Towards Ball Agent. It can run with no dependencies other than RLBot itself.

Key APIs:

examples/simple_flatbuffer (Source)

Another ATBA, but using a secondary interface which uses flatbuffers. Many of the low-level functions in RLBot’s interface make use of flatbuffers.

Key APIs:

examples/rendering (Source)

This example shows how to draw simple shapes to the game window. If you don’t see anything, try pressing PageUp, which is RLBot’s shortcut for turning on rendering.

Key APIs:

examples/gravity (Source)

A fun example showing how to set game state.

Key APIs:

examples/gravity_flatbuffer (Source)

This works exactly the same as the previous example, except it uses the low-level flatbuffer interface.

Key APIs:

examples/bot (Source)

I saved the best for last. This is a full-fledged RLBot bot that can run within the RLBot framework. It’s different than the other examples, in that it requires a working RLBot Python setup. Follow the instructions in RLBotPythonExample to make sure you have all the necessary dependencies installed. Once you have that working, you should be able to run a Rust bot within the framework with this command:

cargo build --example bot && python -c "from rlbot import runner; runner.main()"

Key APIs:

Modules

This module contains data structures used by [RLBot::set_game_state_struct] for state setting.

Structs

A color that can be used to draw in a RenderGroup.
An iterator-like object that yields packets from the game as they occur.
An iterator-like object that yields physics ticks from the game as they occur.
The low-level interface to RLBot. All RLBot calls that are available can be made through this struct.
A render group in the process of being built.

Traits

A bot that can run within the RLBot framework. Instances of Bot are used by the run_bot function.

Functions

Initializes RLBot and returns a ready-to-use RLBot object.
Runs a bot under control of the RLBot framework.