From b12918d10647fafeeccfecd8b9e0919da291d56b Mon Sep 17 00:00:00 2001 From: Richard Williams Date: Sun, 19 Feb 2023 17:16:27 -0800 Subject: [PATCH] For some reason the player races are indexed starting at 1, so that needs to be the default. Also, game_info, game_data, and client cannot be marked as Properties or else an error will be thrown in bot_ai_internal._prepare_start. Also, the observed_id was not being passed into the correct place to allow for correct indexing in _prepare_start --- sc2/main.py | 6 +++--- sc2/observer_ai.py | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sc2/main.py b/sc2/main.py index 5e1b3621..78118b6d 100644 --- a/sc2/main.py +++ b/sc2/main.py @@ -233,7 +233,7 @@ async def _play_game( return result -async def _play_replay(client, ai, realtime=False, player_id=0): +async def _play_replay(client, ai, realtime=False, player_id=1): ai._initialize_variables() game_data = await client.get_game_data() @@ -455,7 +455,7 @@ async def _setup_replay(server, replay_path, realtime, observed_id): async def _host_replay(replay_path, ai, realtime, _portconfig, base_build, data_version, observed_id): async with SC2Process(fullscreen=False, base_build=base_build, data_hash=data_version) as server: client = await _setup_replay(server, replay_path, realtime, observed_id) - result = await _play_replay(client, ai, realtime) + result = await _play_replay(client, ai, realtime, observed_id) return result @@ -498,7 +498,7 @@ async def run_host_and_join(): return result -def run_replay(ai, replay_path, realtime=False, observed_id=0): +def run_replay(ai, replay_path, realtime=False, observed_id=1): portconfig = Portconfig() assert os.path.isfile(replay_path), f"Replay does not exist at the given path: {replay_path}" assert os.path.isabs( diff --git a/sc2/observer_ai.py b/sc2/observer_ai.py index 1f049039..d0fd8946 100644 --- a/sc2/observer_ai.py +++ b/sc2/observer_ai.py @@ -36,17 +36,14 @@ def time_formatted(self) -> str: t = self.time return f"{int(t // 60):02}:{int(t % 60):02}" - @property def game_info(self) -> GameInfo: """ See game_info.py """ return self._game_info - @property def game_data(self) -> GameData: """ See game_data.py """ return self._game_data - @property def client(self) -> Client: """ See client.py """ return self._client