Skip to content

Commit 82ce6a5

Browse files
committed
Update to new flatbuffer spec
1 parent f0a1bc7 commit 82ce6a5

28 files changed

+130
-122
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "A high performance Python interface for communicating with RLBot
88
dynamic = ["version"]
99
requires-python = ">= 3.11"
1010
dependencies = [
11-
"rlbot_flatbuffers~=0.12.0",
11+
"rlbot_flatbuffers~=0.13.0",
1212
"psutil==6.*",
1313
]
1414
readme = "README.md"

rlbot/interface.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SocketDataType(IntEnum):
2727
GAME_PACKET = 1
2828
FIELD_INFO = 2
2929
START_COMMAND = 3
30-
MATCH_SETTINGS = 4
30+
MATCH_CONFIGURATION = 4
3131
PLAYER_INPUT = 5
3232
DESIRED_GAME_STATE = 6
3333
RENDER_GROUP = 7
@@ -63,8 +63,8 @@ class SocketRelay:
6363
on_connect_handlers: list[Callable[[], None]] = []
6464
packet_handlers: list[Callable[[flat.GamePacket], None]] = []
6565
field_info_handlers: list[Callable[[flat.FieldInfo], None]] = []
66-
match_settings_handlers: list[Callable[[flat.MatchSettings], None]] = []
67-
match_communication_handlers: list[Callable[[flat.MatchComm], None]] = []
66+
match_config_handlers: list[Callable[[flat.MatchConfiguration], None]] = []
67+
match_comm_handlers: list[Callable[[flat.MatchComm], None]] = []
6868
ball_prediction_handlers: list[Callable[[flat.BallPrediction], None]] = []
6969
controllable_team_info_handlers: list[
7070
Callable[[flat.ControllableTeamInfo], None]
@@ -151,17 +151,17 @@ def stop_match(self, shutdown_server: bool = False):
151151
flatbuffer = flat.StopCommand(shutdown_server).pack()
152152
self.send_bytes(flatbuffer, SocketDataType.STOP_COMMAND)
153153

154-
def start_match(self, match_config: Path | flat.MatchSettings):
154+
def start_match(self, match_config: Path | flat.MatchConfiguration):
155155
self.logger.info("Python interface is attempting to start match...")
156156

157157
match match_config:
158158
case Path() as path:
159159
string_path = str(path.absolute().resolve())
160160
flatbuffer = flat.StartCommand(string_path).pack()
161161
flat_type = SocketDataType.START_COMMAND
162-
case flat.MatchSettings() as settings:
162+
case flat.MatchConfiguration() as settings:
163163
flatbuffer = settings.pack()
164-
flat_type = SocketDataType.MATCH_SETTINGS
164+
flat_type = SocketDataType.MATCH_CONFIGURATION
165165
case _:
166166
raise ValueError(
167167
"Expected MatchSettings or path to match settings toml file"
@@ -310,15 +310,17 @@ def handle_incoming_message(self, incoming_message: SocketMessage):
310310
field_info = flat.FieldInfo.unpack(incoming_message.data)
311311
for handler in self.field_info_handlers:
312312
handler(field_info)
313-
case SocketDataType.MATCH_SETTINGS:
314-
if len(self.match_settings_handlers) > 0:
315-
match_settings = flat.MatchSettings.unpack(incoming_message.data)
316-
for handler in self.match_settings_handlers:
313+
case SocketDataType.MATCH_CONFIGURATION:
314+
if len(self.match_config_handlers) > 0:
315+
match_settings = flat.MatchConfiguration.unpack(
316+
incoming_message.data
317+
)
318+
for handler in self.match_config_handlers:
317319
handler(match_settings)
318320
case SocketDataType.MATCH_COMMUNICATION:
319-
if len(self.match_communication_handlers) > 0:
321+
if len(self.match_comm_handlers) > 0:
320322
match_comm = flat.MatchComm.unpack(incoming_message.data)
321-
for handler in self.match_communication_handlers:
323+
for handler in self.match_comm_handlers:
322324
handler(match_comm)
323325
case SocketDataType.BALL_PREDICTION:
324326
if len(self.ball_prediction_handlers) > 0:

rlbot/managers/bot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Bot:
2525
name: str = ""
2626
spawn_id: int = 0
2727

28-
match_settings = flat.MatchSettings()
28+
match_config = flat.MatchConfiguration()
2929
"""
3030
Contains info about what map you're on, game mode, mutators, etc.
3131
"""
@@ -60,9 +60,9 @@ def __init__(self, default_agent_id: Optional[str] = None):
6060
exit(1)
6161

6262
self._game_interface = SocketRelay(agent_id, logger=self.logger)
63-
self._game_interface.match_settings_handlers.append(self._handle_match_settings)
63+
self._game_interface.match_config_handlers.append(self._handle_match_config)
6464
self._game_interface.field_info_handlers.append(self._handle_field_info)
65-
self._game_interface.match_communication_handlers.append(
65+
self._game_interface.match_comm_handlers.append(
6666
self._handle_match_communication
6767
)
6868
self._game_interface.ball_prediction_handlers.append(
@@ -86,7 +86,7 @@ def _try_initialize(self):
8686
return
8787

8888
# Search match settings for our name
89-
for player in self.match_settings.player_configurations:
89+
for player in self.match_config.player_configurations:
9090
if player.spawn_id == self.spawn_id:
9191
self.name = player.name
9292
self.logger = get_logger(self.name)
@@ -104,8 +104,8 @@ def _try_initialize(self):
104104
self._initialized_bot = True
105105
self._game_interface.send_init_complete()
106106

107-
def _handle_match_settings(self, match_settings: flat.MatchSettings):
108-
self.match_settings = match_settings
107+
def _handle_match_config(self, match_config: flat.MatchConfiguration):
108+
self.match_config = match_config
109109
self._has_match_settings = True
110110
self._try_initialize()
111111

rlbot/managers/hivemind.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Hivemind:
2727
names: list[str] = []
2828
spawn_ids: list[int] = []
2929

30-
match_settings = flat.MatchSettings()
30+
match_config = flat.MatchConfiguration()
3131
"""
3232
Contains info about what map you're on, game mode, mutators, etc.
3333
"""
@@ -62,9 +62,9 @@ def __init__(self, default_agent_id: Optional[str] = None):
6262
exit(1)
6363

6464
self._game_interface = SocketRelay(agent_id, logger=self._logger)
65-
self._game_interface.match_settings_handlers.append(self._handle_match_settings)
65+
self._game_interface.match_config_handlers.append(self._handle_match_config)
6666
self._game_interface.field_info_handlers.append(self._handle_field_info)
67-
self._game_interface.match_communication_handlers.append(
67+
self._game_interface.match_comm_handlers.append(
6868
self._handle_match_communication
6969
)
7070
self._game_interface.ball_prediction_handlers.append(
@@ -88,7 +88,7 @@ def _try_initialize(self):
8888

8989
# Search match settings for our spawn ids
9090
for spawn_id in self.spawn_ids:
91-
for player in self.match_settings.player_configurations:
91+
for player in self.match_config.player_configurations:
9292
if player.spawn_id == spawn_id:
9393
self.names.append(player.name)
9494
self.loggers.append(get_logger(player.name))
@@ -108,8 +108,8 @@ def _try_initialize(self):
108108
self._initialized_bot = True
109109
self._game_interface.send_init_complete()
110110

111-
def _handle_match_settings(self, match_settings: flat.MatchSettings):
112-
self.match_settings = match_settings
111+
def _handle_match_config(self, match_config: flat.MatchConfiguration):
112+
self.match_config = match_config
113113
self._has_match_settings = True
114114
self._try_initialize()
115115

rlbot/managers/match.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ def connect(
219219
)
220220

221221
def wait_for_first_packet(self):
222-
while self.packet is None or self.packet.game_info.game_status in {
223-
flat.GameStatus.Inactive,
224-
flat.GameStatus.Ended,
222+
while self.packet is None or self.packet.match_info.match_phase in {
223+
flat.MatchPhase.Inactive,
224+
flat.MatchPhase.Ended,
225225
}:
226226
sleep(0.1)
227227

228228
def start_match(
229-
self, settings: Path | flat.MatchSettings, wait_for_start: bool = True
229+
self, config: Path | flat.MatchConfiguration, wait_for_start: bool = True
230230
):
231231
"""
232232
Starts a match using the given match settings or a path to a match settings toml file.
@@ -244,7 +244,7 @@ def start_match(
244244
)
245245
self.rlbot_interface.run(background_thread=True)
246246

247-
self.rlbot_interface.start_match(settings)
247+
self.rlbot_interface.start_match(config)
248248

249249
if not self.initialized:
250250
self.rlbot_interface.send_init_complete()

rlbot/managers/script.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Script:
2222
index: int = 0
2323
name: str = "UnknownScript"
2424

25-
match_settings = flat.MatchSettings()
25+
match_config = flat.MatchConfiguration()
2626
field_info = flat.FieldInfo()
2727
ball_prediction = flat.BallPrediction()
2828

@@ -45,9 +45,9 @@ def __init__(self, default_agent_id: Optional[str] = None):
4545
exit(1)
4646

4747
self._game_interface = SocketRelay(agent_id, logger=self.logger)
48-
self._game_interface.match_settings_handlers.append(self._handle_match_settings)
48+
self._game_interface.match_config_handlers.append(self._handle_match_config)
4949
self._game_interface.field_info_handlers.append(self._handle_field_info)
50-
self._game_interface.match_communication_handlers.append(
50+
self._game_interface.match_comm_handlers.append(
5151
self._handle_match_communication
5252
)
5353
self._game_interface.ball_prediction_handlers.append(
@@ -81,10 +81,10 @@ def _try_initialize(self):
8181
self._initialized_script = True
8282
self._game_interface.send_init_complete()
8383

84-
def _handle_match_settings(self, match_settings: flat.MatchSettings):
85-
self.match_settings = match_settings
84+
def _handle_match_config(self, match_config: flat.MatchConfiguration):
85+
self.match_config = match_config
8686

87-
for i, script in enumerate(match_settings.script_configurations):
87+
for i, script in enumerate(match_config.script_configurations):
8888
if script.agent_id == self._game_interface.agent_id:
8989
self.index = i
9090
self.name = script.name

rlbot/version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0.0-beta.16"
1+
__version__ = "5.0.0-beta.17"
22

33

44
RESET_SEQ = "\033[0m"
@@ -15,6 +15,9 @@ def _get_color(color: int) -> str:
1515
)
1616

1717
RELEASE_NOTES = {
18+
"5.0.0-beta.17": """
19+
- Update to the newest flatbuffers spec
20+
""",
1821
"5.0.0-beta.16": """
1922
- Read `RLBOT_SERVER_IP` environment variable and default to "127.0.0.1"
2023
""",

tests/atba/atba.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
9797
self.test_rendering(packet)
9898

9999
if (
100-
packet.game_info.game_status
100+
packet.match_info.match_phase
101101
not in {
102-
flat.GameStatus.Active,
103-
flat.GameStatus.Kickoff,
102+
flat.MatchPhase.Active,
103+
flat.MatchPhase.Kickoff,
104104
}
105105
or len(packet.balls) == 0
106106
):
@@ -111,9 +111,9 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
111111

112112
if self.match_comms:
113113
# Limit packet spam
114-
if packet.game_info.frame_num - self.last_send >= 360:
114+
if packet.match_info.frame_num - self.last_send >= 360:
115115
self.send_match_comm(b"", "Hello world!", True)
116-
self.last_send = packet.game_info.frame_num
116+
self.last_send = packet.match_info.frame_num
117117

118118
ball_location = Vector2(packet.balls[0].physics.location)
119119

tests/default.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[rlbot]
22
# use this along with launcher = "custom"
3-
# game_path = "legendary"
3+
# launcher_arg = "legendary"
44
# "Steam", "Epic", "Custom"
55
launcher = "steam"
66
# Should RLBot start the bot processes automatically, or will a separate script start them
@@ -17,7 +17,7 @@ skip_replays = false
1717
# Skip the kickoff countdown
1818
start_without_countdown = false
1919
# What should we do if you click run while a match is already in progress?
20-
# "Restart_If_Different", "Restart", "Continue_And_Spawn"
20+
# "RestartIfDifferent", "Restart", "ContinueAndSpawn"
2121
existing_match_behavior = "Restart"
2222
enable_rendering = false
2323
enable_state_setting = true
@@ -26,39 +26,39 @@ auto_save_replay = false
2626
freeplay = false
2727

2828
[mutators]
29-
# "Five_Minutes", "Ten_Minutes", "Twenty_Minutes", "Unlimited"
30-
match_length = "Five_Minutes"
31-
# "Default", "One_Goal", "Three_Goals", "Five_Goals", "Seven Goals", "Unlimited"
29+
# "FiveMinutes", "TenMinutes", "TwentyMinutes", "Unlimited"
30+
match_length = "FiveMinutes"
31+
# "Default", "OneGoal", "ThreeGoals", "FiveGoals", "SevenGoals", "Unlimited"
3232
max_score = "Default"
3333
# "One", "Two", "Four", "Six"
3434
multi_ball = "One"
35-
# "Unlimited", "Five_Max_First_Score", "Five_Max_Random_Team"
35+
# "Unlimited", "FiveMaxFirstScore", "FiveMaxRandomTeam"
3636
overtime = "Unlimited"
37-
# "Default", "Slo_Mo", "Time_Warp"
37+
# "Default", "SloMo", "TimeWarp"
3838
game_speed = "Default"
39-
# "Default", "Slow", "Fast", "Super_Fast"
39+
# "Default", "Slow", "Fast", "SuperFast"
4040
ball_max_speed = "Default"
41-
# "Default", "Cube", "Puck", "Basketball", "Beachball", "Anniversary", "Haunted", "Ekin", "SpookyCube"
41+
# "Default", "Cube", "Puck", "Basketball", "Beachball", "Anniversary", "Haunted", "Ekin"
4242
ball_type = "Default"
43-
# "Default", "Light", "Heavy", "Super_Light", "Curve_Ball", "Beach_Ball_Curve", "Magnus_FutBall"
43+
# "Default", "Light", "Heavy", "SuperLight", "CurveBall", "BeachBallCurve", "MagnusFutBall"
4444
ball_weight = "Default"
4545
# "Default", "Small", "Medium", "Large", "Gigantic"
4646
ball_size = "Default"
47-
# "Default", "Low", "LowishBounciness", "High", "Super_High"
47+
# "Default", "Low", "LowishBounciness", "High", "SuperHigh"
4848
ball_bounciness = "Default"
49-
# "Normal_Boost", "Unlimited_Boost", "Slow_Recharge", "Rapid_Recharge", "No_Boost"
50-
boost_amount = "Normal_Boost"
51-
# "No_Rumble", "Default", "Slow", "Civilized", "Destruction_Derby", "Spring_Loaded", "Spikes_Only", "Spike_Rush", "Haunted_Ball_Beam", "Tactical", "BatmanRumble"
52-
rumble = "No_Rumble"
49+
# "NormalBoost", "UnlimitedBoost", "SlowRecharge", "RapidRecharge", "NoBoost"
50+
boost_amount = "NormalBoost"
51+
# "NoRumble", "Default", "Slow", "Civilized", "DestructionDerby", "SpringLoaded", "SpikesOnly", "SpikeRush", "HauntedBallBeam", "Tactical", "BatmanRumble"
52+
rumble = "NoRumble"
5353
# "One", "OneAndAHalf", "Two", "Five", "Ten"
5454
boost_strength = "One"
55-
# "Default", "Low", "High", "Super_High", "Reverse"
55+
# "Default", "Low", "High", "SuperHigh", "Reverse"
5656
gravity = "Default"
57-
# "Default", "Disabled", "Friendly_Fire", "On_Contact", "On_Contact_FF"
57+
# "Default", "Disabled", "FriendlyFire", "OnContact", "OnContactFF"
5858
demolish = "Default"
59-
# "Three_Seconds", "Two_Seconds", "One_Second", "Disable_Goal_Reset"
60-
respawn_time = "Three_Seconds"
61-
# "Default", "Eleven_Minutes"
59+
# "Three_Seconds", "TwoSeconds", "OneSecond", "DisableGoalReset"
60+
respawn_time = "ThreeSeconds"
61+
# "Default", "ElevenMinutes"
6262
max_time = "Default"
6363
# "Default", "Haunted", "Rugby"
6464
game_event = "Default"

tests/gamemodes/beach_ball.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ game_map_upk = "Stadium_P"
66
[mutators]
77
ball_max_speed = "Fast"
88
ball_type = "Beachball"
9-
ball_weight = "Beach_Ball_Curve"
9+
ball_weight = "BeachBallCurve"
1010
ball_size = "Medium"
1111
ball_bounciness = "High"
1212

0 commit comments

Comments
 (0)