Individual Combat Behaviors
CombatManeuver
dataclass
¶
Bases: Behavior
Execute behaviors sequentially.
Add behaviors
Example:
from ares import AresBot
from ares.behaviors.combat import CombatManeuver
from ares.behaviors.combat.individual import (
DropCargo,
KeepUnitSafe,
PathUnitToTarget,
PickUpCargo,
)
class MyBot(AresBot):
mine_drop_medivac_tag: int
async def on_step(self, iteration):
# Left out here, but `self.mine_drop_medivac_tag`
# bookkeeping is up to the user
medivac: Optional[Unit] = self.unit_tag_dict.get(
self.mine_drop_medivac_tag, None
)
if not medivac:
return
air_grid: np.ndarray = self.mediator.get_air_grid
# initiate a new CombatManeuver
mine_drop: CombatManeuver = CombatManeuver()
# then add behaviors in the order they should be executed
# first priority is picking up units
# (will return False if no cargo and move to next behavior)
mine_drop.add(
PickUpCargo(
unit=medivac,
grid=air_grid,
pickup_targets=mines_to_pickup
)
)
# if there is cargo, path to target and drop them off
if medivac.has_cargo:
# path
mine_drop.add(
PathUnitToTarget(
unit=medivac,
grid=air_grid,
target=self.enemy_start_locations[0],
)
)
# drop off the mines
mine_drop.add(DropCargo(unit=medivac, target=medivac.position))
# no cargo and no units to pick up, stay safe
else:
mine_drop.add(KeepUnitSafe(unit=medivac, grid=air_grid))
# register the mine_drop behavior
self.register_behavior(mine_drop)
Attributes:
Name | Type | Description |
---|---|---|
micros |
list[Behavior]
|
A list of behaviors that should be executed. Defaults to an empty list. |
Source code in src/ares/behaviors/combat/combat_maneuver.py
add(behavior)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
behavior
|
Union[CombatIndividualBehavior, CombatGroupBehavior, CombatManeuver]
|
Add a new combat behavior to the current maneuver object. |
required |
Source code in src/ares/behaviors/combat/combat_maneuver.py
AMove
dataclass
¶
Bases: CombatIndividualBehavior
A-Move a unit to a target.
Example:
from ares.behaviors.combat.individual import AMove
self.register_behavior(AMove(unit, self.game_info.map_center))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to stay safe. |
target |
Union[Point2, Unit]
|
Where the unit is going. |
Source code in src/ares/behaviors/combat/individual/a_move.py
AttackTarget
dataclass
¶
Bases: CombatIndividualBehavior
Shoot a target.
Example:
from ares.behaviors.combat.individual import AttackTarget
unit: Unit
target: Unit
self.register_behavior(AttackTarget(unit, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to shoot. |
target |
Unit
|
The unit we want to shoot at. |
Source code in src/ares/behaviors/combat/individual/attack_target.py
DropCargo
dataclass
¶
Bases: CombatIndividualBehavior
Handle releasing cargo from a container.
Medivacs, WarpPrism, Overlords, Nydus.
Example:
from ares.behaviors.combat import DropCargo
unit: Unit
target: Unit
self.register_behavior(DropCargo(unit, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The container unit. |
target |
Point2
|
The target position where to drop the cargo. |
Source code in src/ares/behaviors/combat/individual/drop_cargo.py
KeepUnitSafe
dataclass
¶
Bases: CombatIndividualBehavior
Get a unit to safety based on the influence grid passed in.
Example:
from ares.behaviors.combat import KeepUnitSafe
unit: Unit
grid: np.ndarray = self.mediator.get_ground_grid
self.register_behavior(KeepUnitSafe(unit, grid))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to stay safe. |
grid |
ndarray
|
2D grid which usually contains enemy influence. |
Source code in src/ares/behaviors/combat/individual/keep_unit_safe.py
MedivacHeal
dataclass
¶
Bases: CombatIndividualBehavior
Given close allied units, heal things up.
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The siege tank unit. |
close_allied |
list[Unit]
|
All close by allied units we want to heal. |
grid |
ndarray
|
The path for medivac to heal on |
keep_safe |
bool
|
Attempt to stay safe, this may result in not always healing units (Default is True) |
Source code in src/ares/behaviors/combat/individual/medivac_heal.py
PathUnitToTarget
dataclass
¶
Bases: CombatIndividualBehavior
Path a unit to its target destination.
Add attack enemy in range logic / parameter
Not added yet since that may be it's own Behavior
Example:
from ares.behaviors.combat import PathUnitToTarget
unit: Unit
grid: np.ndarray = self.mediator.get_ground_grid
target: Point2 = self.game_info.map_center
self.register_behavior(PathUnitToTarget(unit, grid, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to path. |
grid |
ndarray
|
2D grid to path on. |
target |
Point2
|
Target destination. |
success_at_distance |
float
|
If the unit has gotten this close, consider path behavior complete. Defaults to 0.0. |
sensitivity |
int
|
Path precision. Defaults to 5. |
smoothing |
bool
|
Whether to smooth out the path. Defaults to False. |
sense_danger |
bool
|
Whether to check for dangers. If none are present, the pathing query is skipped. Defaults to True. |
danger_distance |
float
|
If |
danger_threshold |
float
|
Influence at which a danger is respected. Defaults to 5.0. |
Source code in src/ares/behaviors/combat/individual/path_unit_to_target.py
PickUpCargo
dataclass
¶
Bases: CombatIndividualBehavior
Handle loading cargo into a container.
Medivacs, WarpPrism, Overlords, Nydus.
Example:
from ares.behaviors.combat import PickUpCargo
unit: Unit # medivac for example
grid: np.ndarray = self.mediator.get_ground_grid
pickup_targets: Union[Units, list[Unit]] = self.workers
self.register_behavior(PickUpCargo(unit, grid, pickup_targets))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The container unit. |
grid |
ndarray
|
Pathing grid for the container unit. |
pickup_targets |
Union[Units, list[Unit]]
|
Units we want to load into the container. |
cargo_switch_to_role |
Optional[UnitRole]
|
Sometimes useful to switch cargo to a new role immediately after loading. Defaults to None. |
Source code in src/ares/behaviors/combat/individual/pick_up_cargo.py
RavenAutoTurret
dataclass
¶
Bases: CombatIndividualBehavior
Drop a turret, opinionated and could be improved Create own behavior based on this if needed.
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
Unit |
all_close_enemy |
list[Unit]
|
All close by allied units we want to heal. |
Source code in src/ares/behaviors/combat/individual/raven_auto_turret.py
SiegeTankDecision
dataclass
¶
Bases: CombatIndividualBehavior
Decide if a tank should either siege or unsiege.
VERY OPINIONATED, recommend to write own version based on this.
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The siege tank unit. |
close_enemy |
list[Unit]
|
All close by enemies. |
target |
Point2
|
Intended destination for this tank. |
stay_sieged_near_target |
bool
|
This is useful for tanks in defensive position. If on offensive, might not be needed Default is False. |
remain_sieged |
bool
|
Sometimes we might just want to leave the tank sieged up Default is False. |
force_unsiege |
bool
|
We might want to not ever siege Default is False. |
Source code in src/ares/behaviors/combat/individual/siege_tank_decision.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
PlacePredictiveAoE
dataclass
¶
Bases: CombatIndividualBehavior
Predict an enemy position and fire AoE accordingly.
Warning: Use this at your own risk. Work in progress.
Guess where the enemy is going based on how it's been moving.
Cythonize this.
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to fire the AoE. |
path |
List[Point2]
|
How we're getting to the target position (the last point in the list). |
enemy_center_unit |
Unit
|
Enemy unit to calculate positions based on. |
aoe_ability |
AbilityId
|
AoE ability to use. |
ability_delay |
int
|
Amount of frames between using the ability and the ability occurring. |
Source code in src/ares/behaviors/combat/individual/place_predictive_aoe.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
ShootTargetInRange
dataclass
¶
Bases: CombatIndividualBehavior
Find something to shoot at.
Currently only picks lowest health.
Might want to pick best one shot KO for example
Example:
from ares.behaviors.combat import ShootTargetInRange
unit: Unit
target: Unit
self.register_behavior(ShootTargetInRange(unit, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to shoot. |
targets |
Union[list[Unit], Units]
|
Units we want to check. |
extra_range |
float
|
Look outside the unit's weapon range. This might be useful for hunting down low HP units. |
Source code in src/ares/behaviors/combat/individual/shoot_target_in_range.py
StutterUnitBack
dataclass
¶
Bases: CombatIndividualBehavior
Shoot at the target if possible, else move back.
Example:
from ares.behaviors.combat import StutterUnitBack
unit: Unit
target: Unit
self.register_behavior(StutterUnitBack(unit, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to shoot. |
target |
Unit
|
The unit we want to shoot at. |
kite_via_pathing |
bool
|
Kite back using pathing? Value for |
grid |
Optional[ndarray]
|
Pass in if using |
Source code in src/ares/behaviors/combat/individual/stutter_unit_back.py
StutterUnitForward
dataclass
¶
Bases: CombatIndividualBehavior
Shoot at the target if possible, else move back.
Example:
from ares.behaviors.combat import StutterUnitForward
unit: Unit
target: Unit
self.register_behavior(StutterUnitForward(unit, target))
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to shoot. |
target |
Unit
|
The unit we want to shoot at. |
Source code in src/ares/behaviors/combat/individual/stutter_unit_forward.py
UseAbility
dataclass
¶
Bases: CombatIndividualBehavior
A-Move a unit to a target.
Example:
from ares.behaviors.combat import UseAbility
from sc2.ids.ability_id import AbilityId
unit: Unit
target: Union[Unit, Point2]
self.register_behavior(
UseAbility(
AbilityId.FUNGALGROWTH_FUNGALGROWTH, unit, target
)
)
Attributes:
Name | Type | Description |
---|---|---|
ability |
AbilityId
|
The ability we want to use. |
unit |
Unit
|
The unit to use the ability. |
target |
Optional[Union[Point2, Unit]]
|
Target for this ability. |
Source code in src/ares/behaviors/combat/individual/use_ability.py
UseAOEAbility
dataclass
¶
Bases: CombatIndividualBehavior
Attempt to use AOE ability for a unit.
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit that potentially has an AOE ability. |
ability_id |
AbilityId
|
Ability we want to use. |
targets |
list[Unit]
|
The targets we want to hit. |
min_targets |
int
|
Minimum targets to hit with spell. |
avoid_own_flying |
bool
|
Avoid own flying with this spell? Default is False. |
avoid_own_ground |
bool
|
Avoid own ground with this spell? Default is False. |
bonus_tags |
Optional[set]
|
Give more emphasize on this unit tags.
For example, perhaps a ravager can do corrosive bile
Provide enemy tags that are currently fungaled?
Default is empty |
recalculate |
bool
|
If unit is already using ability, should we recalculate this behavior? WARNING: could have performance impact Default is False. |
stack_same_spell |
bool
|
Stack spell in same position? Default is False. |
Source code in src/ares/behaviors/combat/individual/use_aoe_ability.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
UseTransfuse
dataclass
¶
Bases: CombatIndividualBehavior
Queen tries to transfuse something
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The queen that should transfuse. |
targets |
Union[list[Unit], Units]
|
Our own units to transfuse. |
extra_range |
float
|
Look a bit further out of transfuse range? Default is 0.0 |
Source code in src/ares/behaviors/combat/individual/use_transfuse.py
WorkerKiteBack
dataclass
¶
Bases: CombatIndividualBehavior
Shoot at the target if possible, else move back.
This is similar to stutter unit back, but takes advantage of mineral walking.
Example:
from ares.behaviors.combat import WorkerKiteBack
unit: Unit
target: Unit
self.register_behavior(
WorkerKiteBack(
unit, target
)
)
Attributes:
Name | Type | Description |
---|---|---|
unit |
Unit
|
The unit to shoot. |
target |
Unit
|
The unit we want to shoot at. |