RLBot
RLBot is a Python framework for developing custom AI bots to play Rocket League in offline matches. It provides access to real-time game data, such as car and ball positions, and allows bots to send controller inputs back to the game. The framework reliably supports up to 10 bots and is actively maintained, with version 5 (v5) introducing significant architectural changes for improved reliability and features, including a shift to WebSocket communication.
Common errors
-
'pip' is not recognized as an internal or external command, operable program or batch file.
cause Python or pip is not correctly added to the system's PATH environment variable, or a virtual environment containing pip is not activated.fixDuring Python installation, ensure 'Add Python to PATH' is selected. If using a virtual environment, activate it with `.\venv\Scripts\activate` (Windows) or `source venv/bin/activate` (Linux/macOS) before running pip commands. You might also need to delete and recreate the virtual environment if an initial setup failed. -
FileNotFoundError: [WinError 2] The system cannot find the file specified
cause This error, along with 'Access is denied' or other WinError messages, often indicates that antivirus software is interfering with RLBot's files or processes.fixAdd the RLBot installation directory and your bot project directories to your antivirus software's exclusion list. Also, check if any RLBot-related `.dll` or `.exe` files have been quarantined or deleted by the antivirus. Restart your computer if issues persist. -
Could not find a version that satisfies the requirement PyQt5 (from versions: none)
cause This error often occurs when the system attempts to use Python 2 instead of Python 3, or when the Python environment is corrupted, and PyQt5 (or other Python 3-specific packages) cannot be found.fixVerify your active Python version with `python --version` or `py -3 --version`. Ensure Python 3 is correctly installed and its path is prioritized in your system's environment variables. If using a virtual environment, ensure it's created with Python 3.
Warnings
- breaking Migration from RLBot v4 to v5 involves breaking changes, primarily moving from `.cfg` configuration files to `.toml` format for bot settings and transitioning bot-to-framework communication from DLLs to WebSockets. Old v4 bots may not be compatible with v5 without modifications.
- gotcha On Windows 10/11, sometimes `AppData\Local\Microsoft\WindowsApps` is in the system PATH, causing `python.exe` to open the Microsoft Store instead of running your Python installation, leading to unexpected behavior or 'nothing printed' errors.
- gotcha RLBot v5 and newer versions require Python 3.12 or later. Using older Python versions will lead to compatibility issues and errors during setup or runtime.
Install
-
pip install rlbot
Imports
- BaseAgent
from rlbot.agents.base_agent import BaseAgent
- SimpleControllerState
from rlbot.agents.base_agent import SimpleControllerState
- GameTickPacket
from rlbot.utils.structures.game_data_struct import GameTickPacket
- RLBotServer.exe
RLBotServer.exe (part of the framework, not a Python import)
Quickstart
import os
from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
from rlbot.utils.structures.game_data_struct import GameTickPacket
class MyBot(BaseAgent):
def initialize_agent(self):
# This runs once before the bot starts.
self.logger.log("MyBot initialized!")
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
# This is called every tick of the game.
# Implement your bot's logic here.
controller_state = SimpleControllerState()
# Example: Drive towards the ball
ball_location = packet.game_ball.physics.location
my_car = packet.game_cars[self.index]
car_location = my_car.physics.location
# Simple steer towards the ball
if ball_location.y > car_location.y:
controller_state.throttle = 1.0
else:
controller_state.throttle = -1.0
# Steering logic (very basic)
if ball_location.x < car_location.x:
controller_state.steer = -1.0
elif ball_location.x > car_location.x:
controller_state.steer = 1.0
else:
controller_state.steer = 0.0
return controller_state
# To run this bot:
# 1. Ensure you have Rocket League installed and RLBot setup (pip install rlbot).
# 2. Typically, you'd clone an example project (e.g., RLBot/python-example),
# place this code in its 'bot.py', and run 'python run.py' from that project's root.
# The RLBot framework will launch Rocket League and your bot automatically.