Fix opponent_id which was set to None even though it was already set to a string value
@@ -51,9 +51,12 @@ class BotAI(DistanceCalculation):
def _initialize_variables(self):
DistanceCalculation.__init__(self)
- # Specific opponent bot ID used in sc2ai ladder games http://sc2ai.net/
+ # Specific opponent bot ID used in sc2ai ladder games http://sc2ai.net/ and on ai arena https://ai-arena.net
# The bot ID will stay the same each game so your bot can "adapt" to the opponent
- self.opponent_id: int = None
+ if not hasattr(self, "opponent_id"):
+ # Prevent overwriting the opponent_id which is set here https://github.com/Hannessa/python-sc2-ladderbot/blob/master/__init__.py#L40
+ # otherwise set it to None
+ self.opponent_id: str = None
# This value will be set to True by main.py in self._prepare_start if game is played in realtime (if true, the bot will have limited time per step)
self.realtime: bool = False
self.all_units: Units = Units([], self)
