-
Notifications
You must be signed in to change notification settings - Fork 27
Combat and Unit Micro
GroupCombatManager
handles how units micro during combat. Combat micro is managed in the following 5 phases:
-
Unit type
inside agroup
andunit micro
: generic_micro.py -
Group handling
: default_micro_methods.py#L30
Before assigning units to combat, you should set their role to what your bot is trying to do with them.
# Add units to combat manager
self.combat.add_unit(unit)
# Order the units in combat manager to do something.
self.combat.execute(self.knowledge.gather_point, MoveType.Assault)
# Unit list in combat manager is automatically cleared.
Combat manager attempts to group units and first tries to combine groups of units together and then move units by their types and finally micro the units individually based on their micro type.
Managing and grouping units is a critical process in how your micro works and it gives your bot a lot of personality on how it fights. There is a decent group management code in sharpy by default, but bot authors using sharpy should eventually write their own that matches the scenarios they want their bot to work best with.
A super aggressive bot might want to stream all of their units to enemy base as fast as they are out. Another bot might have a timing attack build that is reliant on colossus being with the army. For handle group method to work correctly, each group must be assigned a command within the combat manager. Available commands are:
combat.move_to(group, position_to_move, move_type)
combat.attack_to(group, position_to_attack, move_type)
combat.regroup(group, position)
def handle_groups_method(combat: "GroupCombatManager", target: Point2, move_type=MoveType.Assault):
for group in combat.own_groups:
if move_type == MoveType.PanicRetreat:
combat.move_to(group, target, move_type)
else:
combat.attack_to(group, target, move_type)
class ProtossBot(KnowledgeBot):
def configure_managers(self) -> Optional[List[ManagerBase]]:
# When using default regrouping method, this is used to indicate how spread out the units can be
# Percentage 0 - 1 on how many of the attacking units should actually be together when attacking
self.combat.default_rules.regroup_percentage = 0.75
# How much distance must be between units to consider them to be in different groups
self.combat.default_rules.own_group_threshold = 9
# This overrides the default unit regrouping
self.combat.default_rules.handle_groups_func = handle_groups_method
- Plans and Build Order
- Settings, debug and logging
- Structure and Life Cycle
- Unit Roles
- Unit Cache
- Running Games
- Converting Sharpy bot from before 2.0 version
- Converting Sharpy KnowledgeBot to SkeletonBot
- Converting Python bot to minimal Sharpy bot
- OLD: Extending Your Existing Bot With Sharpy
- Packaging For Ladders
- Extending Sharpy
- Advanced Build Order tricks
- Machine Learning With Sharpy