Skip to content

Commit f6708a9

Browse files
committed
Add set_game_state to MatchManager
1 parent f987a7d commit f6708a9

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

rlbot/managers/match.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ def disconnect(self):
177177
def stop_match(self):
178178
self.rlbot_interface.stop_match()
179179

180+
def set_game_state(self, game_state: flat.DesiredGameState):
181+
self.rlbot_interface.send_game_state(game_state)
182+
180183
def shut_down(self, ensure_shutdown=True):
181184
self.logger.info("Shutting down RLBot...")
182185

tests/run_forever.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,41 @@
22
from time import sleep
33

44
from rlbot import flat
5-
from rlbot.managers import MatchManager
5+
from rlbot.managers import MatchManager, get_player_config
6+
from rlbot.utils.maps import GAME_MAP_TO_UPK, STANDARD_MAPS
67

78
CURRENT_FILE = Path(__file__).parent
89

9-
MATCH_CONFIG_PATH = CURRENT_FILE / "series.toml"
10+
BOT_PATH = CURRENT_FILE / "necto/bot.toml"
1011
RLBOT_SERVER_FOLDER = CURRENT_FILE / "../../core/RLBotCS/bin/Release/"
1112

1213
if __name__ == "__main__":
1314
match_manager = MatchManager(RLBOT_SERVER_FOLDER)
1415
match_manager.ensure_server_started()
1516

17+
current_map = -1
18+
19+
match_settings = flat.MatchSettings(
20+
launcher=flat.Launcher.Steam,
21+
auto_start_bots=True,
22+
game_mode=flat.GameMode.Soccer,
23+
enable_state_setting=True,
24+
existing_match_behavior=flat.ExistingMatchBehavior.Continue_And_Spawn,
25+
skip_replays=True,
26+
player_configurations=[
27+
get_player_config(flat.RLBot(), 0, BOT_PATH),
28+
get_player_config(flat.RLBot(), 1, BOT_PATH),
29+
],
30+
)
31+
1632
while True:
17-
match_manager.start_match(MATCH_CONFIG_PATH)
33+
# don't use the same map
34+
current_map = (current_map + 1) % len(STANDARD_MAPS)
35+
match_settings.game_map_upk = GAME_MAP_TO_UPK[STANDARD_MAPS[current_map]]
36+
37+
print(f"Starting match on {match_settings.game_map_upk}")
38+
39+
match_manager.start_match(match_settings)
1840

1941
while (
2042
match_manager.packet is None
@@ -28,13 +50,11 @@
2850
):
2951
match_manager.rlbot_interface.send_game_state(
3052
flat.DesiredGameState(
31-
game_info_state=flat.DesiredGameInfoState(game_speed=5)
53+
game_info_state=flat.DesiredGameInfoState(game_speed=10)
3254
)
3355
)
3456

3557
sleep(0.1)
3658

37-
# let the end screen play for 5 seconds
59+
# let the end screen play for 5 seconds (just for fun)
3860
sleep(5)
39-
match_manager.stop_match()
40-
sleep(1)

0 commit comments

Comments
 (0)