HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

RLBot Beginner Tutorial - Learn Python by playing Rocket League 1/3

37,107 views January 7, 2020 17:17

Watch on YouTube
ChannelLearn Code By Gaming

Description from the creator

RLBot is a framework for making Rocket League bots. In this tutorial, I show you how to get started with Rocket League bot programming by building a basic boost stealing bot. This is a great beginner Python project whether you're looking to build a portfolio, or just want to have some fun learning how to write video game AI.

I’m a big believer in project based learning. If you follow this tutorial to the end, my hope is that you’ll be prepared to continue where we left off, and this will be the launch point for your own creative exploration into the deeper world of Python development and video game artificial intelligence.

Full tutorial playlist: youtube.com/playlist?list=PL1m2M8LQlzfK5YDEb2ov…

Remember to setup GitHub for this project, especially if you plan on showcasing the RLBots you make in your portfolio.

GitHub repo for this project: github.com/learncodebygaming/rlbot_boosthog
Download Python 3 for Windows: python.org/downloads/
Download Visual Studio Code: code.visualstudio.com/download
Buy Rocket League on Steam: store.steampowered.com/app/252950/Rocket_League/
Download RL Bot: rlbot.org/
RLBot Wiki for Input and Output Data: github.com/RLBot/RLBotPythonExample/wiki/Input-…
RLBot Wiki for Item IDs: github.com/RLBot/RLBot/wiki/Item-IDs
RLBot Wiki for Colors and Bot Customization: github.com/RLBot/RLBot/wiki/Bot-Customization

Checkout learncodebygaming.com/ for more programming project ideas.

To get started with making your own Rocket League bot, you'll first need the prerequisites: the Rocket League game, a Python development environment, and the RLBot framework (links for all these above).

The first time you launch RLBotGUI it will take some time to download the needed Python packages. Once that's done, go ahead and get the example bots by clicking on the plus sign and selecting "Download Bot Pack". Add some bots to each team and start a match to confirm that everything installed successfully.

In the Rocket League game window itself, open the start menu, go to "Options" then the "Video" tab, and in the window settings set the display mode to "Windowed", and set the resolution size to something slightly smaller than your monitor resolution. This will allow you to easily switch between the game window and your code as you're developing.

Clicking "Stop" in the RLBotGUI will stop all the bots from running (and this shut down will be indicated in the console window). Inside the game, the match will continue to run, but all bot activity will be stop. You can bring up the start menu to pause the game. You should leave the Rocket League window open so that when you start a new match it will launch faster (but you can close it at this point if you want).

To start a new bot, click the plus sign again in RLBotGUI and select "Start Your Own Bot!". Give it a name and select Python as the language. I'm calling my bot "BoostHog". This will generate a bunch of files for you, including the configuration and source code for your bot. To find where these files are located, click to the right of your bot in the bot selection list. This will open details about the bot, including where the source files are located on your computer. There's also a handy "Show Files" button that will open the file explorer window for you.

Open the folder with your bot files in your Python IDE and let's take a look around. In the "src" directory you'll find: bot.cfg, which is the base configuration file for your bot; appearance.cfg, which controls what your bot's car looks like; and bot.py, which is the main source code controlling the behavior of your bot.

The ID numbers in appearance.cfg correspond with values that can be found in the RLBot wiki.

Open bot.py and you'll see a class called MyBot that extends from BaseAgent. This is the heart of your bot code in the RLBot framework. Every bot must implement two required functions: initialize_agent(), which runs once when the bot starts up; and get_output(), which is called for every game tick.

The get_output() method receives information about the state of the game in the "packet" parameter. Using this information, it must return a SimpleControllerState that describes what controller inputs you want your bot to provide in order to best react to the current game state. Information about the data structure of GameTickPacket and SimpleControllerState can be found in the "Input and Output Data" section of the RLBot wiki.

Rocket League runs at a tick rate of 60 per second. So every 60 seconds, get_output() will be called and you'll have an opportunity to react by changing your controller state: that is, changing what buttons on the gamepad your bot is pressing, and where the joysticks are positioned.

Continue with the written tutorial here: learncodebygaming.com/blog/learn-python-by-play…

About this tutorial

Learn Code By Gaming published this 17:17 video tutorial on January 7, 2020. It has been watched 37,107 times on YouTube.

Category
Education
Duration
17:17
Published
January 7, 2020
Views
37,107
Likes
812

Tags

Share

This tutorial in other languages