Skip to content

Commit f94f430

Browse files
committed
Update to newest spec
1 parent b13b354 commit f94f430

File tree

14 files changed

+49
-55
lines changed

14 files changed

+49
-55
lines changed

rlbot/interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SocketRelay:
6666
_should_continue = True
6767

6868
on_connect_handlers: list[Callable[[], None]] = []
69-
packet_handlers: list[Callable[[flat.GameTickPacket], None]] = []
69+
packet_handlers: list[Callable[[flat.GamePacket], None]] = []
7070
field_info_handlers: list[Callable[[flat.FieldInfo], None]] = []
7171
match_settings_handlers: list[Callable[[flat.MatchSettings], None]] = []
7272
match_communication_handlers: list[Callable[[flat.MatchComm], None]] = []
@@ -269,7 +269,7 @@ def handle_incoming_message(self, incoming_message: SocketMessage):
269269
self._should_continue = False
270270
case SocketDataType.GAME_TICK_PACKET:
271271
if len(self.packet_handlers) > 0:
272-
packet = flat.GameTickPacket.unpack(incoming_message.data)
272+
packet = flat.GamePacket.unpack(incoming_message.data)
273273
for handler in self.packet_handlers:
274274
handler(packet)
275275
case SocketDataType.FIELD_INFO:

rlbot/managers/bot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Bot:
2929
_has_field_info = False
3030
_has_player_mapping = False
3131

32-
_latest_packet: Optional[flat.GameTickPacket] = None
32+
_latest_packet: Optional[flat.GamePacket] = None
3333
_latest_prediction = flat.BallPrediction()
3434

3535
def __init__(self):
@@ -116,10 +116,10 @@ def _handle_player_mappings(self, player_mappings: flat.TeamControllables):
116116
def _handle_ball_prediction(self, ball_prediction: flat.BallPrediction):
117117
self._latest_prediction = ball_prediction
118118

119-
def _handle_packet(self, packet: flat.GameTickPacket):
119+
def _handle_packet(self, packet: flat.GamePacket):
120120
self._latest_packet = packet
121121

122-
def _packet_processor(self, packet: flat.GameTickPacket):
122+
def _packet_processor(self, packet: flat.GamePacket):
123123
if len(packet.players) <= self.index:
124124
return
125125

@@ -151,9 +151,9 @@ def run(
151151

152152
# custom message handling logic
153153
# this reads all data in the socket until there's no more immediately available
154-
# checks if there was a GameTickPacket in the data, and if so, processes it
154+
# checks if there was a GamePacket in the data, and if so, processes it
155155
# then sets the socket to non-blocking and waits for more data
156-
# if there was no GameTickPacket, it sets to blocking and waits for more data
156+
# if there was no GamePacket, it sets to blocking and waits for more data
157157
while True:
158158
try:
159159
self._game_interface.handle_incoming_messages(True)
@@ -274,7 +274,7 @@ def initialize(self):
274274
def retire(self):
275275
"""Called after the game ends"""
276276

277-
def get_output(self, packet: flat.GameTickPacket) -> flat.ControllerState:
277+
def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
278278
"""
279279
Where all the logic of your bot gets its input and returns its output.
280280
"""

rlbot/managers/hivemind.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Hivemind:
3131
_has_field_info = False
3232
_has_player_mapping = False
3333

34-
_latest_packet: Optional[flat.GameTickPacket] = None
34+
_latest_packet: Optional[flat.GamePacket] = None
3535
_latest_prediction = flat.BallPrediction()
3636

3737
def __init__(self):
@@ -115,10 +115,10 @@ def _handle_player_mappings(self, player_mappings: flat.TeamControllables):
115115
def _handle_ball_prediction(self, ball_prediction: flat.BallPrediction):
116116
self._latest_prediction = ball_prediction
117117

118-
def _handle_packet(self, packet: flat.GameTickPacket):
118+
def _handle_packet(self, packet: flat.GamePacket):
119119
self._latest_packet = packet
120120

121-
def _packet_processor(self, packet: flat.GameTickPacket):
121+
def _packet_processor(self, packet: flat.GamePacket):
122122
if len(packet.players) <= self.indices[-1]:
123123
return
124124

@@ -284,9 +284,7 @@ def initialize(self):
284284
def retire(self):
285285
"""Called after the game ends"""
286286

287-
def get_outputs(
288-
self, packet: flat.GameTickPacket
289-
) -> dict[int, flat.ControllerState]:
287+
def get_outputs(self, packet: flat.GamePacket) -> dict[int, flat.ControllerState]:
290288
"""
291289
Where all the logic of your bot gets its input and returns its output.
292290
"""

rlbot/managers/match.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_player_config(
7272
if CURRENT_OS == OS.LINUX and "run_command_linux" in settings:
7373
run_command = settings["run_command_linux"]
7474

75-
loadout_path = settings.get("loadout_config", None)
75+
loadout_path = settings.get("loadout_file", None)
7676
if loadout_path is not None:
7777
loadout_path = parent / loadout_path
7878

@@ -97,7 +97,7 @@ def get_player_config(
9797

9898
class MatchManager:
9999
logger = DEFAULT_LOGGER
100-
packet: Optional[flat.GameTickPacket] = None
100+
packet: Optional[flat.GamePacket] = None
101101
rlbot_server_process: Optional[psutil.Process] = None
102102
rlbot_server_port = RLBOT_SERVER_PORT
103103
initialized = False
@@ -142,13 +142,13 @@ def ensure_server_started(self, print_version_info: bool = True):
142142
self.rlbot_server_process.pid,
143143
)
144144

145-
def _packet_reporter(self, packet: flat.GameTickPacket):
145+
def _packet_reporter(self, packet: flat.GamePacket):
146146
self.packet = packet
147147

148148
def wait_for_valid_packet(self):
149-
while self.packet is not None and self.packet.game_info.game_state_type in {
150-
flat.GameStateType.Inactive,
151-
flat.GameStateType.Ended,
149+
while self.packet is not None and self.packet.game_info.game_status in {
150+
flat.GameStatus.Inactive,
151+
flat.GameStatus.Ended,
152152
}:
153153
sleep(0.1)
154154

rlbot/managers/script.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Script:
2828
_has_field_info = False
2929
_has_player_mapping = False
3030

31-
_latest_packet: Optional[flat.GameTickPacket] = None
31+
_latest_packet: Optional[flat.GamePacket] = None
3232
_latest_prediction = flat.BallPrediction()
3333

3434
def __init__(self):
@@ -108,10 +108,10 @@ def _handle_player_mappings(self, player_mappings: flat.TeamControllables):
108108
def _handle_ball_prediction(self, ball_prediction: flat.BallPrediction):
109109
self._latest_prediction = ball_prediction
110110

111-
def _handle_packet(self, packet: flat.GameTickPacket):
111+
def _handle_packet(self, packet: flat.GamePacket):
112112
self._latest_packet = packet
113113

114-
def _packet_processor(self, packet: flat.GameTickPacket):
114+
def _packet_processor(self, packet: flat.GamePacket):
115115
if len(packet.players) <= self.index:
116116
return
117117

@@ -245,5 +245,5 @@ def initialize(self):
245245
def retire(self):
246246
"""Called after the game ends"""
247247

248-
def handle_packet(self, packet: flat.GameTickPacket):
248+
def handle_packet(self, packet: flat.GamePacket):
249249
pass

tests/atba/atba.bot.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# The name that will be displayed in game
33
name = "ATBA_v5"
44
# Path to loadout config from runner
5-
loadout_config = "../necto/loadout.toml"
5+
loadout_file = "../necto/loadout.toml"
66
# (OPTIONAL) - what you want the working directory set to
77
# This is relative to the location of this file
88
location = ""

tests/atba/atba.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ def handle_match_communication(
8888
):
8989
self.logger.info(f"Received match communication from index {index}! {display}")
9090

91-
def get_output(self, packet: flat.GameTickPacket) -> flat.ControllerState:
91+
def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
9292
if self.rendering:
9393
self.test_rendering(packet)
9494

9595
if (
96-
packet.game_info.game_state_type
96+
packet.game_info.game_status
9797
not in {
98-
flat.GameStateType.Active,
99-
flat.GameStateType.Kickoff,
98+
flat.GameStatus.Active,
99+
flat.GameStatus.Kickoff,
100100
}
101101
or len(packet.balls) == 0
102102
):
@@ -125,7 +125,7 @@ def get_output(self, packet: flat.GameTickPacket) -> flat.ControllerState:
125125

126126
return self.controller
127127

128-
def test_state_setting(self, packet: flat.GameTickPacket):
128+
def test_state_setting(self, packet: flat.GamePacket):
129129
self.set_game_state(
130130
{
131131
0: flat.DesiredBallState(
@@ -146,7 +146,7 @@ def test_state_setting(self, packet: flat.GameTickPacket):
146146
},
147147
)
148148

149-
def test_rendering(self, packet: flat.GameTickPacket):
149+
def test_rendering(self, packet: flat.GamePacket):
150150
if not self.needs_render:
151151
self.needs_render = (
152152
self.last_demoed and packet.players[self.index].demolished_timeout <= 0

tests/hivemind/bot.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ def get_car_facing_vector(car: flat.PlayerInfo) -> Vector2:
5252
class Hives(Hivemind):
5353
controllers: dict[int, flat.ControllerState] = {}
5454

55-
def get_outputs(
56-
self, packet: flat.GameTickPacket
57-
) -> dict[int, flat.ControllerState]:
55+
def get_outputs(self, packet: flat.GamePacket) -> dict[int, flat.ControllerState]:
5856
if (
59-
packet.game_info.game_state_type
57+
packet.game_info.game_status
6058
not in {
61-
flat.GameStateType.Active,
62-
flat.GameStateType.Kickoff,
59+
flat.GameStatus.Active,
60+
flat.GameStatus.Kickoff,
6361
}
6462
or len(packet.balls) == 0
6563
):

tests/hivemind/bot.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[settings]
22
name = "Hives"
3-
loadout_config = "../necto/loadout.toml"
3+
loadout_file = "../necto/loadout.toml"
44
location = ""
55
run_command = "..\\..\\venv\\Scripts\\python bot.py"
66
run_command_linux = "../../venv/bin/python bot.py"

tests/necto/bot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from necto_obs import NectoObsBuilder
55
from rlgym_compat import V1GameState
66

7-
from rlbot.flat import ControllerState, GameStateType, GameTickPacket, Vector3
7+
from rlbot.flat import ControllerState, GameStatus, GamePacket, Vector3
88
from rlbot.managers import Bot
99

1010
KICKOFF_CONTROLS = (
@@ -116,7 +116,7 @@ def render_attention_weights(
116116

117117
self.renderer.end_rendering()
118118

119-
def get_output(self, packet: GameTickPacket) -> ControllerState:
119+
def get_output(self, packet: GamePacket) -> ControllerState:
120120
cur_frame = packet.game_info.frame_num
121121
ticks_elapsed = cur_frame - self.prev_frame
122122
self.prev_frame = cur_frame
@@ -144,7 +144,7 @@ def get_output(self, packet: GameTickPacket) -> ControllerState:
144144
obs = self.obs_builder.build_obs(player, self.game_state, self.action)
145145

146146
beta = self.beta
147-
if packet.game_info.game_state_type == GameStateType.Ended:
147+
if packet.game_info.game_status == GameStatus.Ended:
148148
beta = 0 # Celebrate with random actions
149149
self.action, weights = self.agent.act(obs, beta)
150150

@@ -161,8 +161,8 @@ def get_output(self, packet: GameTickPacket) -> ControllerState:
161161

162162
return self.controls
163163

164-
def maybe_do_kickoff(self, packet: GameTickPacket, ticks_elapsed: int):
165-
if packet.game_info.game_state_type == GameStateType.Kickoff:
164+
def maybe_do_kickoff(self, packet: GamePacket, ticks_elapsed: int):
165+
if packet.game_info.game_status == GameStatus.Kickoff:
166166
if self.kickoff_index >= 0:
167167
self.kickoff_index += round(ticks_elapsed)
168168
elif self.kickoff_index == -1:

0 commit comments

Comments
 (0)