-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_forever.py
More file actions
66 lines (53 loc) · 2.06 KB
/
run_forever.py
File metadata and controls
66 lines (53 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pathlib import Path
from time import sleep
from rlbot import flat
from rlbot.config import load_player_config
from rlbot.managers import MatchManager
from rlbot.utils.gateway import find_file
from rlbot.utils.maps import GAME_MAP_TO_UPK, STANDARD_MAPS
from rlbot.utils.os_detector import RLBOT_SERVER_NAME
DIR = Path(__file__).parent
BOT_PATH = DIR / "atba/atba.bot.toml"
RLBOT_SERVER_PATH = find_file(
DIR / "../../core/RLBotCS/bin/Release/", RLBOT_SERVER_NAME
)
if __name__ == "__main__":
match_manager = MatchManager(RLBOT_SERVER_PATH)
current_map = -1
blue_bot = load_player_config(BOT_PATH, 0)
orange_bot = load_player_config(BOT_PATH, 1)
match_settings = flat.MatchConfiguration(
launcher=flat.Launcher.Steam,
auto_start_agents=True,
game_mode=flat.GameMode.Soccar,
enable_state_setting=True,
existing_match_behavior=flat.ExistingMatchBehavior.Restart,
skip_replays=True,
mutators=flat.MutatorSettings(
match_length=flat.MatchLengthMutator.FiveMinutes,
),
player_configurations=[
blue_bot,
blue_bot,
blue_bot,
orange_bot,
orange_bot,
orange_bot,
],
)
while True:
# don't use the same map
current_map = (current_map + 1) % len(STANDARD_MAPS)
match_settings.game_map_upk = GAME_MAP_TO_UPK[STANDARD_MAPS[current_map]]
print(f"Starting match on {match_settings.game_map_upk}")
match_manager.start_match(match_settings)
# when calling start_match, by default it will wait for the first packet
assert match_manager.packet is not None
while match_manager.packet.match_info.match_phase != flat.MatchPhase.Ended:
if match_manager.packet.match_info.match_phase == flat.MatchPhase.Countdown:
match_manager.set_game_state(
match_info=flat.DesiredMatchInfo(game_speed=2)
)
sleep(1)
# let the end screen play for 5 seconds (just for fun)
sleep(5)