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¶
micros : list[Behavior] (optional, default: []) A list of behaviors that should be executed. (Optional)
Source code in src/ares/behaviors/combat/combat_maneuver.py
13 14 15 16 17 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 |
|
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¶
unit : Unit The unit to stay safe. target: Point2 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¶
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¶
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¶
unit : Unit The unit to stay safe. grid : np.ndarray 2D Grid which usually contains enemy influence.
Source code in src/ares/behaviors/combat/individual/keep_unit_safe.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¶
unit : Unit The unit to path. grid : np.ndarray 2D Grid to path on. target : Point2 Target destination. success_at_distance : float (default: 0.0) If unit has got this close, consider path behavior complete. sensitivity : int (default: 5) Path precision. smoothing : bool (default: False) Smooth out the path. sense_danger : bool (default: True) Check for dangers, if none are present pathing query is skipped. danger_distance : float (default: 20.0) If sense_danger=True, how far to check for dangers? danger_threshold : float (default: 5.0) Influence at which a danger is respected.
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¶
unit : Unit The container unit. grid : np.ndarray Pathing grid for container unit. pickup_targets : Union[Units, list[Unit]] Units we want to load into the container. cargo_switch_to_role : UnitRole (default: None) Sometimes useful to switch cargo tp new role immediately after loading.
Source code in src/ares/behaviors/combat/individual/pick_up_cargo.py
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¶
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 224 225 226 227 |
|
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¶
unit: Unit The unit to shoot. targets : Union[list[Unit], Units] Units we want to check. extra_range: float (optional) Look outside unit 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¶
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
must be present.
grid : Optional[np.ndarray]
Pass in if using kite_via_pathing.
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¶
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¶
ability : AbilityId The ability we want to use. unit : Unit The unit to use the ability. target: Union[Point2, Unit, None] Target for this ability.
Source code in src/ares/behaviors/combat/individual/use_ability.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¶
unit: Unit The unit to shoot. target : Unit The unit we want to shoot at.