File tree Expand file tree Collapse file tree 4 files changed +7
-28
lines changed Expand file tree Collapse file tree 4 files changed +7
-28
lines changed Original file line number Diff line number Diff line change @@ -40,4 +40,4 @@ async def on_step(self, iteration: int):
4040 assert (
4141 replay_path .is_file ()
4242 ), "Run worker_rush.py in the same folder first to generate a replay. Then run watch_replay.py again."
43- run_replay (my_observer_ai , replay_path = replay_path )
43+ run_replay (my_observer_ai , replay_path = str ( replay_path ) )
Original file line number Diff line number Diff line change @@ -476,9 +476,10 @@ def _prepare_start(
476476 self .realtime : bool = realtime
477477 self .base_build : int = base_build
478478
479- self .race : Race = Race (self .game_info .player_races [self .player_id ])
480-
481- if len (self .game_info .player_races ) == 2 :
479+ # Get the player's race. As observer, get Race.NoRace=0
480+ self .race : Race = Race (self .game_info .player_races .get (self .player_id , 0 ))
481+ # Get the enemy's race only if we are not observer (replay) and the game has 2 players
482+ if self .player_id > 0 and len (self .game_info .player_races ) == 2 :
482483 self .enemy_race : Race = Race (self .game_info .player_races [3 - self .player_id ])
483484
484485 self ._distances_override_functions (self .distance_calculation_method )
Original file line number Diff line number Diff line change 1010import numpy as np
1111
1212from sc2 .pixel_map import PixelMap
13- from sc2 .player import Player , Race
13+ from sc2 .player import Player
1414from sc2 .position import Point2 , Rect , Size
1515
1616
@@ -237,7 +237,7 @@ def __init__(self, proto) -> None:
237237 self .map_ramps : list [Ramp ] = None # Filled later by BotAI._prepare_first_step
238238 # pyre-ignore[8]
239239 self .vision_blockers : frozenset [Point2 ] = None # Filled later by BotAI._prepare_first_step
240- self .player_races : dict [int , Race ] = {
240+ self .player_races : dict [int , int ] = {
241241 p .player_id : p .race_actual or p .race_requested for p in self ._proto .player_info
242242 }
243243 self .start_locations : list [Point2 ] = [
Original file line number Diff line number Diff line change 66
77from __future__ import annotations
88
9- from typing import TYPE_CHECKING
10-
119from sc2 .bot_ai_internal import BotAIInternal
1210from sc2 .data import Alert , Result
13- from sc2 .game_data import GameData
1411from sc2 .ids .ability_id import AbilityId
1512from sc2 .ids .upgrade_id import UpgradeId
1613from sc2 .position import Point2
1714from sc2 .unit import Unit
1815from sc2 .units import Units
1916
20- if TYPE_CHECKING :
21- from sc2 .client import Client
22- from sc2 .game_info import GameInfo
23-
2417
2518class ObserverAI (BotAIInternal ):
2619 """Base class for bots."""
@@ -36,21 +29,6 @@ def time_formatted(self) -> str:
3629 t = self .time
3730 return f"{ int (t // 60 ):02} :{ int (t % 60 ):02} "
3831
39- @property
40- def game_info (self ) -> GameInfo :
41- """See game_info.py"""
42- return self ._game_info
43-
44- @property
45- def game_data (self ) -> GameData :
46- """See game_data.py"""
47- return self ._game_data
48-
49- @property
50- def client (self ) -> Client :
51- """See client.py"""
52- return self ._client
53-
5432 def alert (self , alert_code : Alert ) -> bool :
5533 """
5634 Check if alert is triggered in the current step.
You can’t perform that action at this time.
0 commit comments