sc2nachos.state
What an observation reports beyond its units: the score, the supply, effects and this player's actions.
1"""What an observation reports beyond its units: the score, the supply, effects and this player's actions.""" 2 3from sc2nachos.state._action_result import ActionResult, UnknownActionResultError 4from sc2nachos.state._actions import Action, ActionFailure, AutocastToggle, CameraMove, UnitCommand 5from sc2nachos.state._alert import Alert 6from sc2nachos.state._effect import Effect 7from sc2nachos.state._in_production import InProduction 8from sc2nachos.state._research import Research 9from sc2nachos.state._score import CategoryScore, Score, ValueScore, VitalScore 10from sc2nachos.state._supply import Supply 11from sc2nachos.state._ui_unit_counts import UiUnitCounts 12 13__all__ = [ 14 "Action", 15 "ActionFailure", 16 "ActionResult", 17 "Alert", 18 "AutocastToggle", 19 "CameraMove", 20 "CategoryScore", 21 "Effect", 22 "InProduction", 23 "Research", 24 "Score", 25 "Supply", 26 "UiUnitCounts", 27 "UnitCommand", 28 "UnknownActionResultError", 29 "ValueScore", 30 "VitalScore", 31]
25@dataclass(frozen=True, slots=True) 26class Action: 27 """An action of this player's, as the game carried it out: a `UnitCommand`, an `AutocastToggle` or a 28 `CameraMove`.""" 29 30 time: GameTime 31 """When the game carried it out."""
An action of this player's, as the game carried it out: a UnitCommand, an AutocastToggle or a
CameraMove.
114@final 115@dataclass(frozen=True, slots=True) 116class ActionFailure: 117 """An order the game refused when it was sent, or accepted and then gave up on (in game). 118 119 Not an `Action`: an action is something this player did, and this is something the game refused or undid. Not an 120 exception either: the game reports it, and nothing raises it. 121 """ 122 123 time: GameTime 124 """When the order was refused, which is when it was issued, or when the game gave up on it.""" 125 unit: Unit[Any] | None 126 """The unit whose order was refused or given up, or `None` if the game named none. A refusal always names one.""" 127 ability: AbilityId | None 128 """The ability refused, as it was ordered, or the ability given up, or `None` if the game named none.""" 129 action_result: ActionResult 130 """Why: `NOT_ENOUGH_MINERALS` for a build refused as it was sent, `NOT_ENOUGH_FOOD` for a marine with no supply 131 left, `CANT_BUILD_LOCATION_INVALID` for a site taken meanwhile.""" 132 133 @classmethod 134 def _from_proto( 135 cls, error: sc2api_pb2.ActionError, unit_by_tag: Callable[[int], Unit[Any]], time: GameTime 136 ) -> Self: 137 """Read an action error (the protocol's name for it) from the observation at `time`, looking up its unit 138 through `unit_by_tag`. 139 140 Raises `UncuratedIdError` if it names an ability the curated ids leave out. 141 """ 142 unit = unit_by_tag(error.unit_tag) if error.HasField("unit_tag") else None 143 ability = AbilityId.read(error.ability_id) if error.HasField("ability_id") else None 144 return cls(time, unit, ability, ActionResult.read(error.result))
An order the game refused when it was sent, or accepted and then gave up on (in game).
Not an Action: an action is something this player did, and this is something the game refused or undid. Not an
exception either: the game reports it, and nothing raises it.
When the order was refused, which is when it was issued, or when the game gave up on it.
The unit whose order was refused or given up, or None if the game named none. A refusal always names one.
The ability refused, as it was ordered, or the ability given up, or None if the game named none.
Why: NOT_ENOUGH_MINERALS for a build refused as it was sent, NOT_ENOUGH_FOOD for a marine with no supply
left, CANT_BUILD_LOCATION_INVALID for a site taken meanwhile.
24class ActionResult(ReadableIntEnum): 25 """The game's answer to an action, or its reason for giving one up. 26 27 `SUCCESS` means the game accepted the action, not that it carried it out: an order it accepts and then drops is 28 still answered `SUCCESS` (in game). 29 """ 30 31 @classmethod 32 def _unknown(cls, value: int) -> UnknownValueError: 33 return UnknownActionResultError(cls, value) 34 35 SUCCESS = error_pb2.ActionResult.Success 36 NOT_SUPPORTED = error_pb2.ActionResult.NotSupported 37 ERROR = error_pb2.ActionResult.Error 38 CANT_QUEUE_THAT_ORDER = error_pb2.ActionResult.CantQueueThatOrder 39 RETRY = error_pb2.ActionResult.Retry 40 COOLDOWN = error_pb2.ActionResult.Cooldown 41 QUEUE_IS_FULL = error_pb2.ActionResult.QueueIsFull 42 RALLY_QUEUE_IS_FULL = error_pb2.ActionResult.RallyQueueIsFull 43 NOT_ENOUGH_MINERALS = error_pb2.ActionResult.NotEnoughMinerals 44 NOT_ENOUGH_VESPENE = error_pb2.ActionResult.NotEnoughVespene 45 NOT_ENOUGH_TERRAZINE = error_pb2.ActionResult.NotEnoughTerrazine 46 NOT_ENOUGH_CUSTOM = error_pb2.ActionResult.NotEnoughCustom 47 NOT_ENOUGH_FOOD = error_pb2.ActionResult.NotEnoughFood 48 FOOD_USAGE_IMPOSSIBLE = error_pb2.ActionResult.FoodUsageImpossible 49 NOT_ENOUGH_LIFE = error_pb2.ActionResult.NotEnoughLife 50 NOT_ENOUGH_SHIELDS = error_pb2.ActionResult.NotEnoughShields 51 NOT_ENOUGH_ENERGY = error_pb2.ActionResult.NotEnoughEnergy 52 LIFE_SUPPRESSED = error_pb2.ActionResult.LifeSuppressed 53 SHIELDS_SUPPRESSED = error_pb2.ActionResult.ShieldsSuppressed 54 ENERGY_SUPPRESSED = error_pb2.ActionResult.EnergySuppressed 55 NOT_ENOUGH_CHARGES = error_pb2.ActionResult.NotEnoughCharges 56 CANT_ADD_MORE_CHARGES = error_pb2.ActionResult.CantAddMoreCharges 57 TOO_MUCH_MINERALS = error_pb2.ActionResult.TooMuchMinerals 58 TOO_MUCH_VESPENE = error_pb2.ActionResult.TooMuchVespene 59 TOO_MUCH_TERRAZINE = error_pb2.ActionResult.TooMuchTerrazine 60 TOO_MUCH_CUSTOM = error_pb2.ActionResult.TooMuchCustom 61 TOO_MUCH_FOOD = error_pb2.ActionResult.TooMuchFood 62 TOO_MUCH_LIFE = error_pb2.ActionResult.TooMuchLife 63 TOO_MUCH_SHIELDS = error_pb2.ActionResult.TooMuchShields 64 TOO_MUCH_ENERGY = error_pb2.ActionResult.TooMuchEnergy 65 MUST_TARGET_UNIT_WITH_LIFE = error_pb2.ActionResult.MustTargetUnitWithLife 66 MUST_TARGET_UNIT_WITH_SHIELDS = error_pb2.ActionResult.MustTargetUnitWithShields 67 MUST_TARGET_UNIT_WITH_ENERGY = error_pb2.ActionResult.MustTargetUnitWithEnergy 68 CANT_TRADE = error_pb2.ActionResult.CantTrade 69 CANT_SPEND = error_pb2.ActionResult.CantSpend 70 CANT_TARGET_THAT_UNIT = error_pb2.ActionResult.CantTargetThatUnit 71 COULDNT_ALLOCATE_UNIT = error_pb2.ActionResult.CouldntAllocateUnit 72 UNIT_CANT_MOVE = error_pb2.ActionResult.UnitCantMove 73 TRANSPORT_IS_HOLDING_POSITION = error_pb2.ActionResult.TransportIsHoldingPosition 74 BUILD_TECH_REQUIREMENTS_NOT_MET = error_pb2.ActionResult.BuildTechRequirementsNotMet 75 CANT_FIND_PLACEMENT_LOCATION = error_pb2.ActionResult.CantFindPlacementLocation 76 CANT_BUILD_ON_THAT = error_pb2.ActionResult.CantBuildOnThat 77 CANT_BUILD_TOO_CLOSE_TO_DROP_OFF = error_pb2.ActionResult.CantBuildTooCloseToDropOff 78 CANT_BUILD_LOCATION_INVALID = error_pb2.ActionResult.CantBuildLocationInvalid 79 CANT_SEE_BUILD_LOCATION = error_pb2.ActionResult.CantSeeBuildLocation 80 CANT_BUILD_TOO_CLOSE_TO_CREEP_SOURCE = error_pb2.ActionResult.CantBuildTooCloseToCreepSource 81 CANT_BUILD_TOO_CLOSE_TO_RESOURCES = error_pb2.ActionResult.CantBuildTooCloseToResources 82 CANT_BUILD_TOO_FAR_FROM_WATER = error_pb2.ActionResult.CantBuildTooFarFromWater 83 CANT_BUILD_TOO_FAR_FROM_CREEP_SOURCE = error_pb2.ActionResult.CantBuildTooFarFromCreepSource 84 CANT_BUILD_TOO_FAR_FROM_BUILD_POWER_SOURCE = error_pb2.ActionResult.CantBuildTooFarFromBuildPowerSource 85 CANT_BUILD_ON_DENSE_TERRAIN = error_pb2.ActionResult.CantBuildOnDenseTerrain 86 CANT_TRAIN_TOO_FAR_FROM_TRAIN_POWER_SOURCE = error_pb2.ActionResult.CantTrainTooFarFromTrainPowerSource 87 CANT_LAND_LOCATION_INVALID = error_pb2.ActionResult.CantLandLocationInvalid 88 CANT_SEE_LAND_LOCATION = error_pb2.ActionResult.CantSeeLandLocation 89 CANT_LAND_TOO_CLOSE_TO_CREEP_SOURCE = error_pb2.ActionResult.CantLandTooCloseToCreepSource 90 CANT_LAND_TOO_CLOSE_TO_RESOURCES = error_pb2.ActionResult.CantLandTooCloseToResources 91 CANT_LAND_TOO_FAR_FROM_WATER = error_pb2.ActionResult.CantLandTooFarFromWater 92 CANT_LAND_TOO_FAR_FROM_CREEP_SOURCE = error_pb2.ActionResult.CantLandTooFarFromCreepSource 93 CANT_LAND_TOO_FAR_FROM_BUILD_POWER_SOURCE = error_pb2.ActionResult.CantLandTooFarFromBuildPowerSource 94 CANT_LAND_TOO_FAR_FROM_TRAIN_POWER_SOURCE = error_pb2.ActionResult.CantLandTooFarFromTrainPowerSource 95 CANT_LAND_ON_DENSE_TERRAIN = error_pb2.ActionResult.CantLandOnDenseTerrain 96 ADD_ON_TOO_FAR_FROM_BUILDING = error_pb2.ActionResult.AddOnTooFarFromBuilding 97 MUST_BUILD_REFINERY_FIRST = error_pb2.ActionResult.MustBuildRefineryFirst 98 BUILDING_IS_UNDER_CONSTRUCTION = error_pb2.ActionResult.BuildingIsUnderConstruction 99 CANT_FIND_DROP_OFF = error_pb2.ActionResult.CantFindDropOff 100 CANT_LOAD_OTHER_PLAYERS_UNITS = error_pb2.ActionResult.CantLoadOtherPlayersUnits 101 NOT_ENOUGH_ROOM_TO_LOAD_UNIT = error_pb2.ActionResult.NotEnoughRoomToLoadUnit 102 CANT_UNLOAD_UNITS_THERE = error_pb2.ActionResult.CantUnloadUnitsThere 103 CANT_WARP_IN_UNITS_THERE = error_pb2.ActionResult.CantWarpInUnitsThere 104 CANT_LOAD_IMMOBILE_UNITS = error_pb2.ActionResult.CantLoadImmobileUnits 105 CANT_RECHARGE_IMMOBILE_UNITS = error_pb2.ActionResult.CantRechargeImmobileUnits 106 CANT_RECHARGE_UNDER_CONSTRUCTION_UNITS = error_pb2.ActionResult.CantRechargeUnderConstructionUnits 107 CANT_LOAD_THAT_UNIT = error_pb2.ActionResult.CantLoadThatUnit 108 NO_CARGO_TO_UNLOAD = error_pb2.ActionResult.NoCargoToUnload 109 LOAD_ALL_NO_TARGETS_FOUND = error_pb2.ActionResult.LoadAllNoTargetsFound 110 NOT_WHILE_OCCUPIED = error_pb2.ActionResult.NotWhileOccupied 111 CANT_ATTACK_WITHOUT_AMMO = error_pb2.ActionResult.CantAttackWithoutAmmo 112 CANT_HOLD_ANY_MORE_AMMO = error_pb2.ActionResult.CantHoldAnyMoreAmmo 113 TECH_REQUIREMENTS_NOT_MET = error_pb2.ActionResult.TechRequirementsNotMet 114 MUST_LOCKDOWN_UNIT_FIRST = error_pb2.ActionResult.MustLockdownUnitFirst 115 MUST_TARGET_UNIT = error_pb2.ActionResult.MustTargetUnit 116 MUST_TARGET_INVENTORY = error_pb2.ActionResult.MustTargetInventory 117 MUST_TARGET_VISIBLE_UNIT = error_pb2.ActionResult.MustTargetVisibleUnit 118 MUST_TARGET_VISIBLE_LOCATION = error_pb2.ActionResult.MustTargetVisibleLocation 119 MUST_TARGET_WALKABLE_LOCATION = error_pb2.ActionResult.MustTargetWalkableLocation 120 MUST_TARGET_PAWNABLE_UNIT = error_pb2.ActionResult.MustTargetPawnableUnit 121 YOU_CANT_CONTROL_THAT_UNIT = error_pb2.ActionResult.YouCantControlThatUnit 122 YOU_CANT_ISSUE_COMMANDS_TO_THAT_UNIT = error_pb2.ActionResult.YouCantIssueCommandsToThatUnit 123 MUST_TARGET_RESOURCES = error_pb2.ActionResult.MustTargetResources 124 REQUIRES_HEAL_TARGET = error_pb2.ActionResult.RequiresHealTarget 125 REQUIRES_REPAIR_TARGET = error_pb2.ActionResult.RequiresRepairTarget 126 NO_ITEMS_TO_DROP = error_pb2.ActionResult.NoItemsToDrop 127 CANT_HOLD_ANY_MORE_ITEMS = error_pb2.ActionResult.CantHoldAnyMoreItems 128 CANT_HOLD_THAT = error_pb2.ActionResult.CantHoldThat 129 TARGET_HAS_NO_INVENTORY = error_pb2.ActionResult.TargetHasNoInventory 130 CANT_DROP_THIS_ITEM = error_pb2.ActionResult.CantDropThisItem 131 CANT_MOVE_THIS_ITEM = error_pb2.ActionResult.CantMoveThisItem 132 CANT_PAWN_THIS_UNIT = error_pb2.ActionResult.CantPawnThisUnit 133 MUST_TARGET_CASTER = error_pb2.ActionResult.MustTargetCaster 134 CANT_TARGET_CASTER = error_pb2.ActionResult.CantTargetCaster 135 MUST_TARGET_OUTER = error_pb2.ActionResult.MustTargetOuter 136 CANT_TARGET_OUTER = error_pb2.ActionResult.CantTargetOuter 137 MUST_TARGET_YOUR_OWN_UNITS = error_pb2.ActionResult.MustTargetYourOwnUnits 138 CANT_TARGET_YOUR_OWN_UNITS = error_pb2.ActionResult.CantTargetYourOwnUnits 139 MUST_TARGET_FRIENDLY_UNITS = error_pb2.ActionResult.MustTargetFriendlyUnits 140 CANT_TARGET_FRIENDLY_UNITS = error_pb2.ActionResult.CantTargetFriendlyUnits 141 MUST_TARGET_NEUTRAL_UNITS = error_pb2.ActionResult.MustTargetNeutralUnits 142 CANT_TARGET_NEUTRAL_UNITS = error_pb2.ActionResult.CantTargetNeutralUnits 143 MUST_TARGET_ENEMY_UNITS = error_pb2.ActionResult.MustTargetEnemyUnits 144 CANT_TARGET_ENEMY_UNITS = error_pb2.ActionResult.CantTargetEnemyUnits 145 MUST_TARGET_AIR_UNITS = error_pb2.ActionResult.MustTargetAirUnits 146 CANT_TARGET_AIR_UNITS = error_pb2.ActionResult.CantTargetAirUnits 147 MUST_TARGET_GROUND_UNITS = error_pb2.ActionResult.MustTargetGroundUnits 148 CANT_TARGET_GROUND_UNITS = error_pb2.ActionResult.CantTargetGroundUnits 149 MUST_TARGET_STRUCTURES = error_pb2.ActionResult.MustTargetStructures 150 CANT_TARGET_STRUCTURES = error_pb2.ActionResult.CantTargetStructures 151 MUST_TARGET_LIGHT_UNITS = error_pb2.ActionResult.MustTargetLightUnits 152 CANT_TARGET_LIGHT_UNITS = error_pb2.ActionResult.CantTargetLightUnits 153 MUST_TARGET_ARMORED_UNITS = error_pb2.ActionResult.MustTargetArmoredUnits 154 CANT_TARGET_ARMORED_UNITS = error_pb2.ActionResult.CantTargetArmoredUnits 155 MUST_TARGET_BIOLOGICAL_UNITS = error_pb2.ActionResult.MustTargetBiologicalUnits 156 CANT_TARGET_BIOLOGICAL_UNITS = error_pb2.ActionResult.CantTargetBiologicalUnits 157 MUST_TARGET_HEROIC_UNITS = error_pb2.ActionResult.MustTargetHeroicUnits 158 CANT_TARGET_HEROIC_UNITS = error_pb2.ActionResult.CantTargetHeroicUnits 159 MUST_TARGET_ROBOTIC_UNITS = error_pb2.ActionResult.MustTargetRoboticUnits 160 CANT_TARGET_ROBOTIC_UNITS = error_pb2.ActionResult.CantTargetRoboticUnits 161 MUST_TARGET_MECHANICAL_UNITS = error_pb2.ActionResult.MustTargetMechanicalUnits 162 CANT_TARGET_MECHANICAL_UNITS = error_pb2.ActionResult.CantTargetMechanicalUnits 163 MUST_TARGET_PSIONIC_UNITS = error_pb2.ActionResult.MustTargetPsionicUnits 164 CANT_TARGET_PSIONIC_UNITS = error_pb2.ActionResult.CantTargetPsionicUnits 165 MUST_TARGET_MASSIVE_UNITS = error_pb2.ActionResult.MustTargetMassiveUnits 166 CANT_TARGET_MASSIVE_UNITS = error_pb2.ActionResult.CantTargetMassiveUnits 167 MUST_TARGET_MISSILE = error_pb2.ActionResult.MustTargetMissile 168 CANT_TARGET_MISSILE = error_pb2.ActionResult.CantTargetMissile 169 MUST_TARGET_WORKER_UNITS = error_pb2.ActionResult.MustTargetWorkerUnits 170 CANT_TARGET_WORKER_UNITS = error_pb2.ActionResult.CantTargetWorkerUnits 171 MUST_TARGET_ENERGY_CAPABLE_UNITS = error_pb2.ActionResult.MustTargetEnergyCapableUnits 172 CANT_TARGET_ENERGY_CAPABLE_UNITS = error_pb2.ActionResult.CantTargetEnergyCapableUnits 173 MUST_TARGET_SHIELD_CAPABLE_UNITS = error_pb2.ActionResult.MustTargetShieldCapableUnits 174 CANT_TARGET_SHIELD_CAPABLE_UNITS = error_pb2.ActionResult.CantTargetShieldCapableUnits 175 MUST_TARGET_FLYERS = error_pb2.ActionResult.MustTargetFlyers 176 CANT_TARGET_FLYERS = error_pb2.ActionResult.CantTargetFlyers 177 MUST_TARGET_BURIED_UNITS = error_pb2.ActionResult.MustTargetBuriedUnits 178 CANT_TARGET_BURIED_UNITS = error_pb2.ActionResult.CantTargetBuriedUnits 179 MUST_TARGET_CLOAKED_UNITS = error_pb2.ActionResult.MustTargetCloakedUnits 180 CANT_TARGET_CLOAKED_UNITS = error_pb2.ActionResult.CantTargetCloakedUnits 181 MUST_TARGET_UNITS_IN_A_STASIS_FIELD = error_pb2.ActionResult.MustTargetUnitsInAStasisField 182 CANT_TARGET_UNITS_IN_A_STASIS_FIELD = error_pb2.ActionResult.CantTargetUnitsInAStasisField 183 MUST_TARGET_UNDER_CONSTRUCTION_UNITS = error_pb2.ActionResult.MustTargetUnderConstructionUnits 184 CANT_TARGET_UNDER_CONSTRUCTION_UNITS = error_pb2.ActionResult.CantTargetUnderConstructionUnits 185 MUST_TARGET_DEAD_UNITS = error_pb2.ActionResult.MustTargetDeadUnits 186 CANT_TARGET_DEAD_UNITS = error_pb2.ActionResult.CantTargetDeadUnits 187 MUST_TARGET_REVIVABLE_UNITS = error_pb2.ActionResult.MustTargetRevivableUnits 188 CANT_TARGET_REVIVABLE_UNITS = error_pb2.ActionResult.CantTargetRevivableUnits 189 MUST_TARGET_HIDDEN_UNITS = error_pb2.ActionResult.MustTargetHiddenUnits 190 CANT_TARGET_HIDDEN_UNITS = error_pb2.ActionResult.CantTargetHiddenUnits 191 CANT_RECHARGE_OTHER_PLAYERS_UNITS = error_pb2.ActionResult.CantRechargeOtherPlayersUnits 192 MUST_TARGET_HALLUCINATIONS = error_pb2.ActionResult.MustTargetHallucinations 193 CANT_TARGET_HALLUCINATIONS = error_pb2.ActionResult.CantTargetHallucinations 194 MUST_TARGET_INVULNERABLE_UNITS = error_pb2.ActionResult.MustTargetInvulnerableUnits 195 CANT_TARGET_INVULNERABLE_UNITS = error_pb2.ActionResult.CantTargetInvulnerableUnits 196 MUST_TARGET_DETECTED_UNITS = error_pb2.ActionResult.MustTargetDetectedUnits 197 CANT_TARGET_DETECTED_UNITS = error_pb2.ActionResult.CantTargetDetectedUnits 198 CANT_TARGET_UNIT_WITH_ENERGY = error_pb2.ActionResult.CantTargetUnitWithEnergy 199 CANT_TARGET_UNIT_WITH_SHIELDS = error_pb2.ActionResult.CantTargetUnitWithShields 200 MUST_TARGET_UNCOMMANDABLE_UNITS = error_pb2.ActionResult.MustTargetUncommandableUnits 201 CANT_TARGET_UNCOMMANDABLE_UNITS = error_pb2.ActionResult.CantTargetUncommandableUnits 202 MUST_TARGET_PREVENT_DEFEAT_UNITS = error_pb2.ActionResult.MustTargetPreventDefeatUnits 203 CANT_TARGET_PREVENT_DEFEAT_UNITS = error_pb2.ActionResult.CantTargetPreventDefeatUnits 204 MUST_TARGET_PREVENT_REVEAL_UNITS = error_pb2.ActionResult.MustTargetPreventRevealUnits 205 CANT_TARGET_PREVENT_REVEAL_UNITS = error_pb2.ActionResult.CantTargetPreventRevealUnits 206 MUST_TARGET_PASSIVE_UNITS = error_pb2.ActionResult.MustTargetPassiveUnits 207 CANT_TARGET_PASSIVE_UNITS = error_pb2.ActionResult.CantTargetPassiveUnits 208 MUST_TARGET_STUNNED_UNITS = error_pb2.ActionResult.MustTargetStunnedUnits 209 CANT_TARGET_STUNNED_UNITS = error_pb2.ActionResult.CantTargetStunnedUnits 210 MUST_TARGET_SUMMONED_UNITS = error_pb2.ActionResult.MustTargetSummonedUnits 211 CANT_TARGET_SUMMONED_UNITS = error_pb2.ActionResult.CantTargetSummonedUnits 212 MUST_TARGET_USER1 = error_pb2.ActionResult.MustTargetUser1 213 CANT_TARGET_USER1 = error_pb2.ActionResult.CantTargetUser1 214 MUST_TARGET_UNSTOPPABLE_UNITS = error_pb2.ActionResult.MustTargetUnstoppableUnits 215 CANT_TARGET_UNSTOPPABLE_UNITS = error_pb2.ActionResult.CantTargetUnstoppableUnits 216 MUST_TARGET_RESISTANT_UNITS = error_pb2.ActionResult.MustTargetResistantUnits 217 CANT_TARGET_RESISTANT_UNITS = error_pb2.ActionResult.CantTargetResistantUnits 218 MUST_TARGET_DAZED_UNITS = error_pb2.ActionResult.MustTargetDazedUnits 219 CANT_TARGET_DAZED_UNITS = error_pb2.ActionResult.CantTargetDazedUnits 220 CANT_LOCKDOWN = error_pb2.ActionResult.CantLockdown 221 CANT_MIND_CONTROL = error_pb2.ActionResult.CantMindControl 222 MUST_TARGET_DESTRUCTIBLES = error_pb2.ActionResult.MustTargetDestructibles 223 CANT_TARGET_DESTRUCTIBLES = error_pb2.ActionResult.CantTargetDestructibles 224 MUST_TARGET_ITEMS = error_pb2.ActionResult.MustTargetItems 225 CANT_TARGET_ITEMS = error_pb2.ActionResult.CantTargetItems 226 NO_CALLDOWN_AVAILABLE = error_pb2.ActionResult.NoCalldownAvailable 227 WAYPOINT_LIST_FULL = error_pb2.ActionResult.WaypointListFull 228 MUST_TARGET_RACE = error_pb2.ActionResult.MustTargetRace 229 CANT_TARGET_RACE = error_pb2.ActionResult.CantTargetRace 230 MUST_TARGET_SIMILAR_UNITS = error_pb2.ActionResult.MustTargetSimilarUnits 231 CANT_TARGET_SIMILAR_UNITS = error_pb2.ActionResult.CantTargetSimilarUnits 232 CANT_FIND_ENOUGH_TARGETS = error_pb2.ActionResult.CantFindEnoughTargets 233 ALREADY_SPAWNING_LARVA = error_pb2.ActionResult.AlreadySpawningLarva 234 CANT_TARGET_EXHAUSTED_RESOURCES = error_pb2.ActionResult.CantTargetExhaustedResources 235 CANT_USE_MINIMAP = error_pb2.ActionResult.CantUseMinimap 236 CANT_USE_INFO_PANEL = error_pb2.ActionResult.CantUseInfoPanel 237 ORDER_QUEUE_IS_FULL = error_pb2.ActionResult.OrderQueueIsFull 238 CANT_HARVEST_THAT_RESOURCE = error_pb2.ActionResult.CantHarvestThatResource 239 HARVESTERS_NOT_REQUIRED = error_pb2.ActionResult.HarvestersNotRequired 240 ALREADY_TARGETED = error_pb2.ActionResult.AlreadyTargeted 241 CANT_ATTACK_WEAPONS_DISABLED = error_pb2.ActionResult.CantAttackWeaponsDisabled 242 COULDNT_REACH_TARGET = error_pb2.ActionResult.CouldntReachTarget 243 TARGET_IS_OUT_OF_RANGE = error_pb2.ActionResult.TargetIsOutOfRange 244 TARGET_IS_TOO_CLOSE = error_pb2.ActionResult.TargetIsTooClose 245 TARGET_IS_OUT_OF_ARC = error_pb2.ActionResult.TargetIsOutOfArc 246 CANT_FIND_TELEPORT_LOCATION = error_pb2.ActionResult.CantFindTeleportLocation 247 INVALID_ITEM_CLASS = error_pb2.ActionResult.InvalidItemClass 248 CANT_FIND_CANCEL_ORDER = error_pb2.ActionResult.CantFindCancelOrder
The game's answer to an action, or its reason for giving one up.
SUCCESS means the game accepted the action, not that it carried it out: an order it accepts and then drops is
still answered SUCCESS (in game).
11class Alert(ReadableIntEnum): 12 """An alert the game raised for this player. An alert names no unit and no position. 13 14 What each docstring says raises the alert was seen in game. The protocol's `AlertError` and `TrainError` have no 15 member: the game raised neither, reporting a failed order as an action error instead. Should it raise either, 16 it is skipped. 17 """ 18 19 NUCLEAR_LAUNCH_DETECTED = _ALERT.NuclearLaunchDetected 20 """The enemy launched a nuke, whether or not this player sees where it is aimed. One alert per nuke. This player's 21 own nukes raise nothing.""" 22 NYDUS_WORM_DETECTED = _ALERT.NydusWormDetected 23 """The enemy summoned a nydus worm, whether or not this player sees where. One alert per worm. This player's own 24 worms raise only `BUILDING_COMPLETE`.""" 25 ADD_ON_COMPLETE = _ALERT.AddOnComplete 26 """An add-on of this player's finished. One alert per add-on.""" 27 BUILDING_COMPLETE = _ALERT.BuildingComplete 28 """A structure of this player's finished: built, morphed from a drone, or a nydus worm, but not an add-on. One 29 alert per structure.""" 30 BUILDING_UNDER_ATTACK = _ALERT.BuildingUnderAttack 31 """A structure of this player's, off camera, came under attack. See `UNIT_UNDER_ATTACK` for when the game 32 raises none.""" 33 LARVA_HATCHED = _ALERT.LarvaHatched 34 """A queen's inject hatched its larva. One alert per inject, a few steps before the larva are seen. Larva a 35 hatchery makes by itself raise none.""" 36 MERGE_COMPLETE = _ALERT.MergeComplete 37 """Two templar of this player's merged into an archon. One alert per archon, some 100 steps after the archon is 38 first seen.""" 39 MINERALS_EXHAUSTED = _ALERT.MineralsExhausted 40 """A mineral field this player mined ran out. One alert per field, in the observation the field is gone from.""" 41 MORPH_COMPLETE = _ALERT.MorphComplete 42 """A unit or structure of this player's finished morphing: a lair, a baneling, an overseer or a ravager. One alert 43 per morph. A hellion becoming a hellbat raises none.""" 44 MOTHERSHIP_COMPLETE = _ALERT.MothershipComplete 45 """A mothership of this player's finished. It raises no `TRAIN_UNIT_COMPLETE`.""" 46 MULE_EXPIRED = _ALERT.MULEExpired 47 """A MULE of this player's expired. One alert per MULE, in the observation that reports it dead.""" 48 NUKE_COMPLETE = _ALERT.NukeComplete 49 """A nuke was armed at a ghost academy of this player's.""" 50 RESEARCH_COMPLETE = _ALERT.ResearchComplete 51 """A research of this player's that is not a level finished: stimpack, combat shield, zergling speed, warp gate or 52 charge. One alert per research.""" 53 TRAIN_UNIT_COMPLETE = _ALERT.TrainUnitComplete 54 """A unit of this player's other than a worker was trained or hatched. One alert per unit, so two for a pair of 55 zerglings. A mothership, a warp-in and a morph raise alerts of their own.""" 56 TRAIN_WORKER_COMPLETE = _ALERT.TrainWorkerComplete 57 """A worker of this player's was trained or hatched. One alert per worker.""" 58 TRANSFORMATION_COMPLETE = _ALERT.TransformationComplete 59 """A gateway of this player's became a warp gate, or a warp gate a gateway. One alert per transformation, 60 including the gateways that warp gate research turns by itself.""" 61 UNIT_UNDER_ATTACK = _ALERT.UnitUnderAttack 62 """A unit of this player's, off camera, came under attack. 63 64 The game raises none for a unit on camera, and none again for a unit until it has gone some 6000 steps without 65 being attacked, counted per unit. 66 67 The camera starts on the main base, with its townhall, workers, mineral fields and geysers on screen, and stays 68 there until moved, so an attack on the main raises none. `OwnUnitDamagedEvent` reports every unit of this 69 player's that loses health or shields, every turn, whatever the camera shows. 70 """ 71 UPGRADE_COMPLETE = _ALERT.UpgradeComplete 72 """A level of this player's weapons or armor finished, or a command center became an orbital command or a 73 planetary fortress. One alert per upgrade.""" 74 VESPENE_EXHAUSTED = _ALERT.VespeneExhausted 75 """A geyser this player mined ran out. One alert per geyser.""" 76 WARP_IN_COMPLETE = _ALERT.WarpInComplete 77 """A unit of this player's finished warping in. One alert per unit."""
An alert the game raised for this player. An alert names no unit and no position.
What each docstring says raises the alert was seen in game. The protocol's AlertError and TrainError have no
member: the game raised neither, reporting a failed order as an action error instead. Should it raise either,
it is skipped.
The enemy launched a nuke, whether or not this player sees where it is aimed. One alert per nuke. This player's own nukes raise nothing.
The enemy summoned a nydus worm, whether or not this player sees where. One alert per worm. This player's own
worms raise only BUILDING_COMPLETE.
An add-on of this player's finished. One alert per add-on.
A structure of this player's finished: built, morphed from a drone, or a nydus worm, but not an add-on. One alert per structure.
A structure of this player's, off camera, came under attack. See UNIT_UNDER_ATTACK for when the game
raises none.
A queen's inject hatched its larva. One alert per inject, a few steps before the larva are seen. Larva a hatchery makes by itself raise none.
Two templar of this player's merged into an archon. One alert per archon, some 100 steps after the archon is first seen.
A mineral field this player mined ran out. One alert per field, in the observation the field is gone from.
A unit or structure of this player's finished morphing: a lair, a baneling, an overseer or a ravager. One alert per morph. A hellion becoming a hellbat raises none.
A mothership of this player's finished. It raises no TRAIN_UNIT_COMPLETE.
A MULE of this player's expired. One alert per MULE, in the observation that reports it dead.
A research of this player's that is not a level finished: stimpack, combat shield, zergling speed, warp gate or charge. One alert per research.
A unit of this player's other than a worker was trained or hatched. One alert per unit, so two for a pair of zerglings. A mothership, a warp-in and a morph raise alerts of their own.
A worker of this player's was trained or hatched. One alert per worker.
A gateway of this player's became a warp gate, or a warp gate a gateway. One alert per transformation, including the gateways that warp gate research turns by itself.
A unit of this player's, off camera, came under attack.
The game raises none for a unit on camera, and none again for a unit until it has gone some 6000 steps without being attacked, counted per unit.
The camera starts on the main base, with its townhall, workers, mineral fields and geysers on screen, and stays
there until moved, so an attack on the main raises none. OwnUnitDamagedEvent reports every unit of this
player's that loses health or shields, every turn, whatever the camera shows.
A level of this player's weapons or armor finished, or a command center became an orbital command or a planetary fortress. One alert per upgrade.
A geyser this player mined ran out. One alert per geyser.
A unit of this player's finished warping in. One alert per unit.
87@final 88@dataclass(frozen=True, slots=True) 89class AutocastToggle(Action): 90 """Units of this player's that had an ability's autocast turned on or off.""" 91 92 ability: AbilityId 93 units: Units[Unit[Any]] 94 """The units whose autocast was toggled, leaving out any the game names by a tag it never reported.""" 95 96 @classmethod 97 def _from_proto( 98 cls, time: GameTime, toggle: raw_pb2.ActionRawToggleAutocast, unit_by_tag: Callable[[int], Unit[Any] | None] 99 ) -> Self: 100 """Read a toggle the observation at `time` reports, looking up its units through `unit_by_tag`, which gives 101 `None` for a tag the game never reported.""" 102 return cls(time, AbilityId.read(toggle.ability_id), _units_reported_under(toggle.unit_tags, unit_by_tag))
Units of this player's that had an ability's autocast turned on or off.
The units whose autocast was toggled, leaving out any the game names by a tag it never reported.
105@final 106@dataclass(frozen=True, slots=True) 107class CameraMove(Action): 108 """A move of this player's camera. The game moves it once itself, as a game starts.""" 109 110 center: Point 111 """Where the camera was centered."""
A move of this player's camera. The game moves it once itself, as a game starts.
16@final 17@dataclass(frozen=True, slots=True) 18class CategoryScore: 19 """An amount split by category.""" 20 21 none: float 22 """Whatever the game's tables give no category.""" 23 army: float 24 """Military units, not workers.""" 25 economy: float 26 """Townhalls, supply structures, gas buildings and workers.""" 27 technology: float 28 """Structures that produce units or research, such as a barracks or an engineering bay.""" 29 upgrade: float 30 """Upgrades, such as warp gate or weapons.""" 31 32 @property 33 def total(self) -> float: 34 """The sum over every category.""" 35 return self.none + self.army + self.economy + self.technology + self.upgrade 36 37 @classmethod 38 def _from_proto(cls, proto: score_pb2.CategoryScoreDetails) -> Self: 39 return cls(proto.none, proto.army, proto.economy, proto.technology, proto.upgrade)
An amount split by category.
17@final 18@dataclass(frozen=True, slots=True) 19class Effect: 20 """An effect an ability leaves on the ground for a while, such as a storm or a corrosive bile about to land. 21 22 The game reports force fields, reaper grenades and a parasitic bomb that has left its target as units, not effects. 23 """ 24 25 id: EffectId 26 positions: tuple[Point, ...] 27 """Where it is: one point, or several along a line, as for a lurker's spines.""" 28 radius: float 29 """How far it reaches from each of its positions.""" 30 alliance: Alliance 31 """Whose side its owner is on.""" 32 owner_id: int 33 """The id of the player it belongs to.""" 34 35 @classmethod 36 def _from_proto(cls, proto: raw_pb2.Effect) -> Self: 37 """Read an effect an observation reports. Raises `UncuratedIdError` for an effect the curated ids leave out.""" 38 return cls( 39 id=EffectId.read(proto.effect_id), 40 positions=tuple(Point((position.x, position.y)) for position in proto.pos), 41 radius=proto.radius, 42 alliance=Alliance(proto.alliance), 43 owner_id=proto.owner, 44 )
An effect an ability leaves on the ground for a while, such as a storm or a corrosive bile about to land.
The game reports force fields, reaper grenades and a parasitic bomb that has left its target as units, not effects.
Where it is: one point, or several along a line, as for a lurker's spines.
16@final 17@dataclass(frozen=True, slots=True) 18class InProduction(Progress[UnitTypeId]): 19 """One unit this player is making, started or paid for and on its way, and how far it has got. 20 21 `fraction` is 0 for a queued train, and for a build or an add-on not begun yet, and a structure's morph and a 22 cocoon's, whose progress the game does not report, are at their producer's `Unit.morph_progress`. `total_time` is 23 the tables' build time rounded up, as `UnitTypeData` gives it (in game), but for a warp-in, which takes 256 steps or 24 81 as where it warps in decides, told apart by how far it has gone up since the observation before the one that 25 first listed it (in game): in a realtime game, or on the ladder, a fast one can read slow for its first two 26 observations. `time_left` is exact at the normal rate (in game), and a cocoon's to within a step: a chrono boost 27 makes it sooner, and a Terran structure whose SCV has left stops, its time left with it. A train queued behind 28 another has all its time left and waits for the one ahead first, and a build or an add-on not begun waits for its 29 worker or its host. 30 """ 31 32 producer: OwnUnit[Any] | None 33 """What makes it: the structure training it, the egg or cocoon, the worker sent to build it, the structure morphing 34 into it, or for a structure going up, its `builder`: an SCV, an add-on's host, a queen planting a creep tumor, or 35 the drone that became it, which has left the observation. `None` for a unit warping in, for an archon two high 36 templar merged into, and for a structure nobody is building, such as a Protoss one.""" 37 unit: OwnUnit[Any] | None 38 """The unit itself while it goes up, warps in or merges into an archon. `None` before it stands: for a train, an 39 egg's or a cocoon's morph, a structure's morph, and a build or an add-on not begun."""
One unit this player is making, started or paid for and on its way, and how far it has got.
fraction is 0 for a queued train, and for a build or an add-on not begun yet, and a structure's morph and a
cocoon's, whose progress the game does not report, are at their producer's Unit.morph_progress. total_time is
the tables' build time rounded up, as UnitTypeData gives it (in game), but for a warp-in, which takes 256 steps or
81 as where it warps in decides, told apart by how far it has gone up since the observation before the one that
first listed it (in game): in a realtime game, or on the ladder, a fast one can read slow for its first two
observations. time_left is exact at the normal rate (in game), and a cocoon's to within a step: a chrono boost
makes it sooner, and a Terran structure whose SCV has left stops, its time left with it. A train queued behind
another has all its time left and waits for the one ahead first, and a build or an add-on not begun waits for its
worker or its host.
What makes it: the structure training it, the egg or cocoon, the worker sent to build it, the structure morphing
into it, or for a structure going up, its builder: an SCV, an add-on's host, a queen planting a creep tumor, or
the drone that became it, which has left the observation. None for a unit warping in, for an archon two high
templar merged into, and for a structure nobody is building, such as a Protoss one.
The unit itself while it goes up, warps in or merges into an archon. None before it stands: for a train, an
egg's or a cocoon's morph, a structure's morph, and a build or an add-on not begun.
16@final 17@dataclass(frozen=True, slots=True) 18class Research(Progress[UpgradeId]): 19 """One research this player has running, or queued behind another, as a structure's orders show it, and how far it 20 has got. 21 22 `fraction` is the game's, 0 for one queued behind another. `total_time` is the tables' research time, a whole number 23 of steps (in game), and `time_left` is exact at the normal rate (in game): a chrono boost makes it sooner, and one 24 queued behind another has all its time left and waits for the one ahead first. 25 """ 26 27 unit: OwnUnit[Any] 28 """The structure researching it."""
One research this player has running, or queued behind another, as a structure's orders show it, and how far it has got.
fraction is the game's, 0 for one queued behind another. total_time is the tables' research time, a whole number
of steps (in game), and time_left is exact at the normal rate (in game): a chrono boost makes it sooner, and one
queued behind another has all its time left and waits for the one ahead first.
75@final 76@dataclass(frozen=True, slots=True) 77class Score: 78 """The score the game keeps for this player, as of the last observation. 79 80 The game's recent APM is left out: it reads zero in a game played through the raw interface. 81 """ 82 83 score: int 84 """The score the game shows at the end of a game: the value of all units and structures, finished or not, plus 85 the resources in the bank.""" 86 idle_production_time: GameTime 87 """The time production structures have spent producing nothing, summed over the structures: a whole number of 88 steps.""" 89 idle_worker_time: GameTime 90 """The time workers have spent neither mining nor building, summed over the workers: a whole number of steps.""" 91 total_value: ValueScore 92 """The value of the finished units and structures.""" 93 killed_value: ValueScore 94 """The value of the opponent's units and structures this player destroyed.""" 95 collected: Resources 96 collection_rate: Resources 97 """The current income per minute.""" 98 spent: Resources 99 """The resources spent. Counted when an order is queued and refunded when it is cancelled.""" 100 food_used: CategoryScore 101 """The supply in use.""" 102 killed_minerals: CategoryScore 103 """The mineral cost of the opponent's units and structures this player destroyed.""" 104 killed_vespene: CategoryScore 105 """The vespene cost of the opponent's units and structures this player destroyed.""" 106 lost_minerals: CategoryScore 107 """The mineral cost of this player's units and structures that were destroyed.""" 108 lost_vespene: CategoryScore 109 """The vespene cost of this player's units and structures that were destroyed.""" 110 friendly_fire_minerals: CategoryScore 111 """The mineral cost of this player's units and structures that it destroyed itself.""" 112 friendly_fire_vespene: CategoryScore 113 """The vespene cost of this player's units and structures that it destroyed itself.""" 114 used_minerals: CategoryScore 115 """The mineral cost of this player's units, structures and upgrades, less those destroyed.""" 116 used_vespene: CategoryScore 117 """The vespene cost of this player's units, structures and upgrades, less those destroyed.""" 118 total_used_minerals: CategoryScore 119 """The mineral cost of this player's units, structures and upgrades over the whole game, those destroyed 120 included.""" 121 total_used_vespene: CategoryScore 122 """The vespene cost of this player's units, structures and upgrades over the whole game, those destroyed 123 included.""" 124 total_damage_dealt: VitalScore 125 """The damage dealt to the opponent.""" 126 total_damage_taken: VitalScore 127 """The damage this player's units and structures have taken.""" 128 total_healed: VitalScore 129 """The healing and repair this player has done.""" 130 131 @classmethod 132 def _from_proto(cls, proto: score_pb2.Score) -> Self: 133 """Read the score an observation reports.""" 134 details = proto.score_details 135 category = CategoryScore._from_proto 136 vital = VitalScore._from_proto 137 return cls( 138 score=proto.score, 139 # The game counts these in seconds at Normal speed, always a whole number of steps (corpus). 140 idle_production_time=GameTime(normal_seconds=details.idle_production_time), 141 idle_worker_time=GameTime(normal_seconds=details.idle_worker_time), 142 total_value=ValueScore(details.total_value_units, details.total_value_structures), 143 killed_value=ValueScore(details.killed_value_units, details.killed_value_structures), 144 collected=Resources(details.collected_minerals, details.collected_vespene), 145 collection_rate=Resources(details.collection_rate_minerals, details.collection_rate_vespene), 146 spent=Resources(details.spent_minerals, details.spent_vespene), 147 food_used=category(details.food_used), 148 killed_minerals=category(details.killed_minerals), 149 killed_vespene=category(details.killed_vespene), 150 lost_minerals=category(details.lost_minerals), 151 lost_vespene=category(details.lost_vespene), 152 friendly_fire_minerals=category(details.friendly_fire_minerals), 153 friendly_fire_vespene=category(details.friendly_fire_vespene), 154 used_minerals=category(details.used_minerals), 155 used_vespene=category(details.used_vespene), 156 total_used_minerals=category(details.total_used_minerals), 157 total_used_vespene=category(details.total_used_vespene), 158 total_damage_dealt=vital(details.total_damage_dealt), 159 total_damage_taken=vital(details.total_damage_taken), 160 total_healed=vital(details.total_healed), 161 )
The score the game keeps for this player, as of the last observation.
The game's recent APM is left out: it reads zero in a game played through the raw interface.
The score the game shows at the end of a game: the value of all units and structures, finished or not, plus the resources in the bank.
The time production structures have spent producing nothing, summed over the structures: a whole number of steps.
The time workers have spent neither mining nor building, summed over the workers: a whole number of steps.
The resources spent. Counted when an order is queued and refunded when it is cancelled.
The mineral cost of the opponent's units and structures this player destroyed.
The vespene cost of the opponent's units and structures this player destroyed.
The mineral cost of this player's units and structures that were destroyed.
The vespene cost of this player's units and structures that were destroyed.
The mineral cost of this player's units and structures that it destroyed itself.
The vespene cost of this player's units and structures that it destroyed itself.
The mineral cost of this player's units, structures and upgrades, less those destroyed.
The vespene cost of this player's units, structures and upgrades, less those destroyed.
The mineral cost of this player's units, structures and upgrades over the whole game, those destroyed included.
The vespene cost of this player's units, structures and upgrades over the whole game, those destroyed included.
10@final 11@dataclass(frozen=True, slots=True) 12class Supply: 13 """The supply this player's units take and its structures and units provide.""" 14 15 used: float 16 """The supply this player's units take, including those in production. A zergling or a baneling takes half.""" 17 cap: int 18 """The supply this player's structures and units provide, up to the game's limit.""" 19 army: float 20 """The supply this player's units other than workers take.""" 21 workers: int 22 """The supply this player's workers take, not counting those in production.""" 23 24 @property 25 def left(self) -> float: 26 """The supply still free under the cap. Negative once units that provided supply are lost.""" 27 return self.cap - self.used
The supply this player's units take and its structures and units provide.
10@final 11@dataclass(frozen=True, slots=True) 12class UiUnitCounts: 13 """The counts of this player's units the game's interface shows beside the minimap, as the game counts them.""" 14 15 idle_workers: int 16 """The workers with nothing to do.""" 17 army: int 18 """The units other than workers.""" 19 warp_gates: int 20 """The warp gates."""
The counts of this player's units the game's interface shows beside the minimap, as the game counts them.
34@final 35@dataclass(frozen=True, slots=True) 36class UnitCommand(Action): 37 """An order given to units of this player's.""" 38 39 ability: AbilityId 40 """The ability ordered, as the game runs it: an action several types perform reads as that action, whichever 41 type's own id the game names, and a research names its level (in game).""" 42 units: Units[Unit[Any]] 43 """The units that took the order, leaving out any the game names by a tag it never reported.""" 44 _target: Target | Literal[_NotReported.TARGET] | None 45 queued: bool 46 """Whether the order was queued behind the units' orders instead of replacing them.""" 47 48 @property 49 def target(self) -> Target | None: 50 """The point or unit the order was aimed at, or `None` for an order that takes neither. Raises 51 `NotReportedError` for a unit the game names by a tag it never reports, as it names a mineral field in the fog 52 that a gather was sent to by its snapshot's tag (in game).""" 53 if self._target is _NotReported.TARGET: 54 raise NotReportedError( 55 f"the game names the unit this {self.ability.name} was aimed at by no tag it reports" 56 ) 57 return self._target 58 59 @property 60 def known_target(self) -> Target | None: 61 """`target`, or `None` where `target` raises. `None` also for an order aimed at nothing; `target` tells the 62 two apart.""" 63 return None if self._target is _NotReported.TARGET else self._target 64 65 @classmethod 66 def _from_proto( 67 cls, 68 time: GameTime, 69 command: raw_pb2.ActionRawUnitCommand, 70 unit_by_tag: Callable[[int], Unit[Any] | None], 71 ) -> Self: 72 """Read a command the observation at `time` reports, looking up the units commanded and the unit it was aimed 73 at through `unit_by_tag`, which gives `None` for a tag the game never reported.""" 74 match command.WhichOneof("target"): 75 case "target_world_space_pos": 76 position = command.target_world_space_pos 77 target: Target | Literal[_NotReported.TARGET] | None = Point((position.x, position.y)) 78 case "target_unit_tag": 79 target_unit = unit_by_tag(command.target_unit_tag) 80 target = _NotReported.TARGET if target_unit is None else target_unit 81 case _: 82 target = None 83 units = _units_reported_under(command.unit_tags, unit_by_tag) 84 return cls(time, AbilityId.read(command.ability_id), units, target, command.queue_command)
An order given to units of this player's.
The ability ordered, as the game runs it: an action several types perform reads as that action, whichever type's own id the game names, and a research names its level (in game).
The units that took the order, leaving out any the game names by a tag it never reported.
48 @property 49 def target(self) -> Target | None: 50 """The point or unit the order was aimed at, or `None` for an order that takes neither. Raises 51 `NotReportedError` for a unit the game names by a tag it never reports, as it names a mineral field in the fog 52 that a gather was sent to by its snapshot's tag (in game).""" 53 if self._target is _NotReported.TARGET: 54 raise NotReportedError( 55 f"the game names the unit this {self.ability.name} was aimed at by no tag it reports" 56 ) 57 return self._target
The point or unit the order was aimed at, or None for an order that takes neither. Raises
NotReportedError for a unit the game names by a tag it never reports, as it names a mineral field in the fog
that a gather was sent to by its snapshot's tag (in game).
12class UnknownActionResultError(UnknownValueError): 13 """The game answered with a result `ActionResult` lacks, added by a protocol release newer than the one it was 14 generated from. Regenerate it with `tools/generate_action_results.py`.""" 15 16 def __init__(self, enum: type[ReadableIntEnum], value: int) -> None: 17 super().__init__(enum, value) 18 self.args = ( 19 f"ActionResult has no member for the result {value} the game answered with, so it is older than the " 20 f"game: regenerate it with tools/generate_action_results.py", 21 )
The game answered with a result ActionResult lacks, added by a protocol release newer than the one it was
generated from. Regenerate it with tools/generate_action_results.py.
61@final 62@dataclass(frozen=True, slots=True) 63class ValueScore: 64 """The cost of units and structures, minerals and vespene together.""" 65 66 units: float 67 structures: float 68 69 @property 70 def total(self) -> float: 71 """The value of the units and structures together.""" 72 return self.units + self.structures
The cost of units and structures, minerals and vespene together.
42@final 43@dataclass(frozen=True, slots=True) 44class VitalScore: 45 """An amount of damage or healing, split by what it took from or gave back.""" 46 47 life: float 48 shields: float 49 energy: float 50 51 @property 52 def total(self) -> float: 53 """The sum over life, shields and energy.""" 54 return self.life + self.shields + self.energy 55 56 @classmethod 57 def _from_proto(cls, proto: score_pb2.VitalScoreDetails) -> Self: 58 return cls(proto.life, proto.shields, proto.energy)
An amount of damage or healing, split by what it took from or gave back.