Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8f60593
make sc2_version accepted by old join and host methods
Jan 17, 2025
422c6e1
Update versions backlog and include `5.0.14.93333` which 5.0.14 maps …
Jun 5, 2025
a640683
Fixes example observer file TypeError: Cannot set ... replay_path to …
Jun 26, 2025
7edff5a
Repairs ObserverAI by removing deprecated field usage and assigning r…
Jun 26, 2025
cba825f
Makes unit.tag be @cached_property
Jun 26, 2025
a04340b
Adds ActionObserverCameraMove.distance for wider Observers zoom-out
Jun 26, 2025
d9623b6
Adds ActionObserverCameraMove.distance to proto, enabling wide zoom-out
Jun 26, 2025
e8f3c3a
Update generate_ids.py to add abilities with empty 'buttonname' in st…
BurnySc2 Jun 26, 2025
8a2a90e
Bump github actions upload-artifact from v3 to v4
BurnySc2 Jun 26, 2025
6462973
Merge pull request #219 from BurnySc2/fix-id-generation-for-frenzy
BurnySc2 Jun 26, 2025
a1795cf
Merge pull request #217 from dysonreturns/unit-tag-cached-property
BurnySc2 Jun 27, 2025
44e12b2
Merge pull request #218 from dysonreturns/observer-distance-field
BurnySc2 Jun 27, 2025
b9eac33
Update ids and dicts using an updated data.json
BurnySc2 Jun 27, 2025
dd9244f
Merge branch 'old-launcher-accept-sc2_version' of github.com:dysonret…
BurnySc2 Jun 27, 2025
558e4c3
Run autoformat
BurnySc2 Jun 27, 2025
06096ca
Merge pull request #213 from dysonreturns/old-launcher-accept-sc2_ver…
BurnySc2 Jun 27, 2025
06100fc
Merge branch 'observer-fixes' of github.com:dysonreturns/python-sc2 i…
BurnySc2 Jun 27, 2025
3ae99a9
Deduplicate function call '_distances_override_functions'
BurnySc2 Jun 27, 2025
2ca0d04
Remove unused import
BurnySc2 Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
rm -rf sc2/dicts/__pycache__ sc2/dicts_old/__pycache__

- name: Upload generated dicts folder as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Generated_dicts
path: sc2/dicts
Expand Down Expand Up @@ -333,7 +333,7 @@ jobs:
echo "Upload htmlcov folder because it was mounted in container, so it will be available in host machine"

- name: Upload htmlcov/ folder as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Coverage_report
path: htmlcov
Expand Down
2 changes: 1 addition & 1 deletion data/data.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/watch_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ async def on_step(self, iteration: int):
assert (
replay_path.is_file()
), "Run worker_rush.py in the same folder first to generate a replay. Then run watch_replay.py again."
run_replay(my_observer_ai, replay_path=replay_path)
run_replay(my_observer_ai, replay_path=str(replay_path))
7 changes: 4 additions & 3 deletions sc2/bot_ai_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,10 @@ def _prepare_start(
self.realtime: bool = realtime
self.base_build: int = base_build

self.race: Race = Race(self.game_info.player_races[self.player_id])

if len(self.game_info.player_races) == 2:
# Get the player's race. As observer, get Race.NoRace=0
self.race: Race = Race(self.game_info.player_races.get(self.player_id, 0))
# Get the enemy's race only if we are not observer (replay) and the game has 2 players
if self.player_id > 0 and len(self.game_info.player_races) == 2:
self.enemy_race: Race = Race(self.game_info.player_races[3 - self.player_id])

self._distances_override_functions(self.distance_calculation_method)
Expand Down
6 changes: 4 additions & 2 deletions sc2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async def move_camera(self, position: Unit | Units | Point2 | Point3) -> None:
)
)

async def obs_move_camera(self, position: Unit | Units | Point2 | Point3) -> None:
async def obs_move_camera(self, position: Unit | Units | Point2 | Point3, distance: float = 0) -> None:
"""Moves observer camera to the target position. Only works when observing (e.g. watching the replay).

:param position:"""
Expand All @@ -444,7 +444,9 @@ async def obs_move_camera(self, position: Unit | Units | Point2 | Point3) -> Non
await self._execute(
obs_action=sc_pb.RequestObserverAction(
actions=[
sc_pb.ObserverAction(camera_move=sc_pb.ActionObserverCameraMove(world_pos=position.as_Point2D))
sc_pb.ObserverAction(
camera_move=sc_pb.ActionObserverCameraMove(world_pos=position.as_Point2D, distance=distance)
)
]
)
)
Expand Down
3 changes: 2 additions & 1 deletion sc2/dicts/generic_redirect_abilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.ability_id import AbilityId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand Down Expand Up @@ -118,6 +119,7 @@
AbilityId.CANCEL_STASISTRAP: AbilityId.CANCEL,
AbilityId.CANCEL_VOIDRAYPRISMATICALIGNMENT: AbilityId.CANCEL,
AbilityId.CHANNELSNIPE_CANCEL: AbilityId.CANCEL,
AbilityId.COMMANDCENTERTRANSPORT_COMMANDCENTERTRANSPORT: AbilityId.LOAD,
AbilityId.CYBERNETICSCORERESEARCH_PROTOSSAIRARMORLEVEL1: AbilityId.RESEARCH_PROTOSSAIRARMOR,
AbilityId.CYBERNETICSCORERESEARCH_PROTOSSAIRARMORLEVEL2: AbilityId.RESEARCH_PROTOSSAIRARMOR,
AbilityId.CYBERNETICSCORERESEARCH_PROTOSSAIRARMORLEVEL3: AbilityId.RESEARCH_PROTOSSAIRARMOR,
Expand Down Expand Up @@ -204,7 +206,6 @@
AbilityId.MORPHTOSWARMHOSTBURROWEDMP_CANCEL: AbilityId.CANCEL,
AbilityId.MOVE_BATTLECRUISER: AbilityId.MOVE,
AbilityId.MOVE_MOVE: AbilityId.MOVE,
AbilityId.NULL_NULL: AbilityId.CANCEL,
AbilityId.PATROL_BATTLECRUISER: AbilityId.PATROL,
AbilityId.PATROL_PATROL: AbilityId.PATROL,
AbilityId.PHASINGMODE_CANCEL: AbilityId.CANCEL,
Expand Down
4 changes: 3 additions & 1 deletion sc2/dicts/unit_abilities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# THIS FILE WAS AUTOMATICALLY GENERATED BY "generate_dicts_from_data_json.py" DO NOT CHANGE MANUALLY!
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId
from sc2.ids.ability_id import AbilityId
from sc2.ids.unit_typeid import UnitTypeId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand Down Expand Up @@ -528,6 +529,7 @@
AbilityId.ATTACK_ATTACK,
AbilityId.BURROWDOWN_HYDRALISK,
AbilityId.HOLDPOSITION_HOLD,
AbilityId.HYDRALISKFRENZY_HYDRALISKFRENZY,
AbilityId.MORPH_LURKER,
AbilityId.MOVE_MOVE,
AbilityId.PATROL_PATROL,
Expand Down
8 changes: 4 additions & 4 deletions sc2/dicts/unit_research_abilities.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# THIS FILE WAS AUTOMATICALLY GENERATED BY "generate_dicts_from_data_json.py" DO NOT CHANGE MANUALLY!
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId
from sc2.ids.ability_id import AbilityId
from sc2.ids.upgrade_id import UpgradeId
# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

from typing import Union

from sc2.ids.ability_id import AbilityId
from sc2.ids.unit_typeid import UnitTypeId
from sc2.ids.upgrade_id import UpgradeId

RESEARCH_INFO: dict[UnitTypeId, dict[UpgradeId, dict[str, Union[AbilityId, bool, UnitTypeId, UpgradeId]]]] = {
UnitTypeId.ARMORY: {
UpgradeId.TERRANSHIPWEAPONSLEVEL1: {"ability": AbilityId.ARMORYRESEARCH_TERRANSHIPWEAPONSLEVEL1},
Expand Down
1 change: 1 addition & 0 deletions sc2/dicts/unit_tech_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand Down
6 changes: 3 additions & 3 deletions sc2/dicts/unit_train_build_abilities.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# THIS FILE WAS AUTOMATICALLY GENERATED BY "generate_dicts_from_data_json.py" DO NOT CHANGE MANUALLY!
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId
from sc2.ids.ability_id import AbilityId
# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

from typing import Union

from sc2.ids.ability_id import AbilityId
from sc2.ids.unit_typeid import UnitTypeId

TRAIN_INFO: dict[UnitTypeId, dict[UnitTypeId, dict[str, Union[AbilityId, bool, UnitTypeId]]]] = {
UnitTypeId.BARRACKS: {
UnitTypeId.GHOST: {
Expand Down
3 changes: 2 additions & 1 deletion sc2/dicts/unit_trained_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand All @@ -23,7 +24,7 @@
UnitTypeId.COLOSSUS: {UnitTypeId.ROBOTICSFACILITY},
UnitTypeId.COMMANDCENTER: {UnitTypeId.SCV},
UnitTypeId.CORRUPTOR: {UnitTypeId.LARVA},
UnitTypeId.CREEPTUMOR: {UnitTypeId.CREEPTUMOR, UnitTypeId.CREEPTUMORBURROWED, UnitTypeId.QUEEN},
UnitTypeId.CREEPTUMOR: {UnitTypeId.CREEPTUMORBURROWED, UnitTypeId.QUEEN},
UnitTypeId.CREEPTUMORQUEEN: {UnitTypeId.QUEEN},
UnitTypeId.CYBERNETICSCORE: {UnitTypeId.PROBE},
UnitTypeId.CYCLONE: {UnitTypeId.FACTORY},
Expand Down
1 change: 1 addition & 0 deletions sc2/dicts/unit_unit_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# ANY CHANGE WILL BE OVERWRITTEN

from sc2.ids.unit_typeid import UnitTypeId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand Down
1 change: 1 addition & 0 deletions sc2/dicts/upgrade_researched_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from sc2.ids.unit_typeid import UnitTypeId
from sc2.ids.upgrade_id import UpgradeId

# from sc2.ids.buff_id import BuffId
# from sc2.ids.effect_id import EffectId

Expand Down
4 changes: 2 additions & 2 deletions sc2/game_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from sc2.pixel_map import PixelMap
from sc2.player import Player, Race
from sc2.player import Player
from sc2.position import Point2, Rect, Size


Expand Down Expand Up @@ -237,7 +237,7 @@ def __init__(self, proto) -> None:
self.map_ramps: list[Ramp] = None # Filled later by BotAI._prepare_first_step
# pyre-ignore[8]
self.vision_blockers: frozenset[Point2] = None # Filled later by BotAI._prepare_first_step
self.player_races: dict[int, Race] = {
self.player_races: dict[int, int] = {
p.player_id: p.race_actual or p.race_requested for p in self._proto.player_info
}
self.start_locations: list[Point2] = [
Expand Down
3 changes: 3 additions & 0 deletions sc2/generate_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def parse_data(self, data) -> dict[str, Any]:
key = v["buttonname"]
remapid = v.get("remapid")

if key == "" and v["index"] == 0:
key = v["name"]

if (not key) and (remapid is None):
assert v["buttonname"] == ""
continue
Expand Down
1 change: 1 addition & 0 deletions sc2/ids/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pyre-ignore-all-errors[14]
from __future__ import annotations

# DO NOT EDIT!
# This file was automatically generated by "generate_ids.py"

Expand Down
Loading
Loading