rlbot/
lib.rs

1//! [![crates.io](https://img.shields.io/crates/v/rlbot.svg)](https://crates.io/crates/rlbot)
2//! [![docs](https://docs.rs/rlbot/badge.svg)](https://docs.rs/rlbot/)
3//! [![Build Status](https://travis-ci.org/whatisaphone/rlbot-rust.svg?branch=master)](https://travis-ci.org/whatisaphone/rlbot-rust)
4//!
5//! <img src="https://github.com/whatisaphone/rlbot-rust/raw/master/assets/logo.png" height="128" style="float:left;margin:0 16px 0 0" />
6//!
7//! [RLBot] is a framework for creating offline Rocket League bots. This crate
8//! lets you write bots using a simple, safe interface that should feel
9//! comfortable to Rust developers.
10//!
11//! [RLBot]: https://github.com/RLBot/RLBot
12//!
13//! Most types in this crate are exported directly from RLBot, so for anything
14//! not documented here, you'll need to use RLBot's docs as the authoritative
15//! reference.
16//!
17//! There are two ways to use this crate:
18//!
19//! 1. [`run_bot`] and [`Bot`] – This is the **high-level** interface. It plays
20//!    a single match from start to finish. It expects the app to have been
21//!    launched by the RLBot framework, and runs its own game loop under
22//!    framework control.
23//! 2. [`init`](init()) and [`RLBot`] – This is the **low-level** interface. You
24//!    can use this to directly access the innards of RLBot for scripting,
25//!    integration tests, or any other custom use-case.
26//!
27//! ## Examples
28//!
29//! This crate comes with plenty examples to get you started. All the examples
30//! can be run directly from the repo. Follow these steps to run an example:
31//!
32//! 1. Run Rocket League with the `-rlbot` flag. The flag causes Rocket League
33//!    to start a local UDP server that lets RLBot control the game. It also
34//!    disables the online features of the game.
35//!
36//!    ```sh
37//!    Steam.exe -applaunch 252950 -rlbot
38//!    ```
39//!
40//! 1. Run `RLBot.exe`, which is included as part of the Python `rlbot` package.
41//!    This is a service process that helps bots communicate with the game.
42//!
43//! 1. Run the example (here we run the example called `simple`):
44//!
45//!    ```sh
46//!    cargo run --example simple
47//!    ```
48//!
49//! ### examples/simple ([Source][`examples/simple`])
50//!
51//! This is a simple ATBA, or **A**lways **T**owards **B**all **A**gent.
52//!
53//! Key APIs:
54//!
55//! * [`init`](init())
56//! * [`RLBot::start_match`]
57//! * [`Packeteer::next`]
58//! * [`RLBot::update_player_input`]
59//!
60//! ### examples/simple_flatbuffer ([Source][`examples/simple_flatbuffer`])
61//!
62//! Another ATBA, but using the lower-level flatbuffer functions. All of the
63//! low-level functions in RLBot's interface make use of flatbuffers.
64//!
65//! Key APIs:
66//!
67//! * [`Packeteer::next_flatbuffer`]
68//! * [`RLBot::update_player_input_flatbuffer`]
69//!
70//! ### examples/rendering ([Source][`examples/rendering`])
71//!
72//! This example shows how to draw simple shapes to the game window. If you
73//! don't see anything, try pressing PageUp, which is RLBot's shortcut for
74//! turning on rendering.
75//!
76//! Key APIs:
77//!
78//! * [`RLBot::begin_render_group`]
79//! * [`RenderGroup::render`]
80//!
81//! ### examples/gravity ([Source][`examples/gravity`])
82//!
83//! A fun example showing how to set game state.
84//!
85//! Key APIs:
86//!
87//! * [`RLBot::set_game_state_struct`]
88//!
89//! ### examples/gravity_flatbuffer ([Source][`examples/gravity_flatbuffer`])
90//!
91//! This works exactly the same as the previous example, except it uses the
92//! low-level flatbuffer interface.
93//!
94//! Key APIs:
95//!
96//! * [`RLBot::set_game_state`]
97//!
98//! ### examples/bot ([Source][`examples/bot`])
99//!
100//! I saved the best for last. This is a full-fledged RLBot bot that can run
101//! within the RLBot framework. It's different than the other examples, in that
102//! it requires a working RLBot Python setup. Follow the instructions in
103//! [RLBotPythonExample] to make sure you have all the necessary dependencies
104//! installed. Once you have that working, you are ready to roll.
105//!
106//! Do not run Rocket League or RLBot.exe—the framework will take care of that
107//! automatically. Just run this command:
108//!
109//! ```sh
110//! cargo build --example bot && python -c "from rlbot import runner; runner.main()"
111//! ```
112//!
113//! Key APIs:
114//!
115//! * [`run_bot`]
116//!
117//! [`examples/bot`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/bot/main.rs
118//! [`examples/simple`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/simple.rs
119//! [`examples/simple_flatbuffer`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/simple_flatbuffer.rs
120//! [`examples/rendering`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/rendering.rs
121//! [`examples/gravity`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/gravity.rs
122//! [`examples/gravity_flatbuffer`]: https://github.com/whatisaphone/rlbot-rust/blob/master/examples/gravity_flatbuffer.rs
123//! [RLBotPythonExample]: https://github.com/RLBot/RLBotPythonExample
124
125#![warn(future_incompatible, rust_2018_compatibility, rust_2018_idioms, unused)]
126#![cfg_attr(feature = "strict", deny(warnings))]
127#![warn(missing_docs, clippy::all)]
128#![allow(intra_doc_link_resolution_failure)]
129
130pub use crate::{
131    framework::{parse_framework_args, run_bot, Bot, FrameworkArgs},
132    game::*,
133    init::{init, init_with_options, InitOptions},
134    match_settings::*,
135    packeteer::Packeteer,
136    physicist::Physicist,
137    render::{Color, RenderGroup},
138    rlbot::RLBot,
139    rlbot_generated::rlbot::flat,
140    state::*,
141};
142
143mod dll;
144mod error;
145pub mod ffi;
146mod ffi_impls;
147mod framework;
148mod game;
149mod game_deserialize;
150mod init;
151mod interface;
152mod match_settings;
153mod packeteer;
154mod physicist;
155mod render;
156mod rlbot;
157#[allow(non_camel_case_types, non_snake_case, missing_docs, clippy::all)]
158mod rlbot_generated;
159mod state;
160mod state_convert;
161#[cfg(feature = "nalgebra")]
162mod state_nalgebra;
163mod utils;