API Reference
Utilize the menu to delve into the available functionalities, currently organized into three primary sections:
Behaviors
- Discover the art of crafting personalized combat maneuvers or macro plans. Each Behavior can be executed individually, tailored to your specific requirements.Manager mediator
- Seamlessly orchestrating numerous managers in the background, the mediator serves as the recommended approach to access data and functions within these managers.
Convenient methods globally available:
AresBot ¶
Bases: CustomBotAI
Final setup of CustomBotAI for usage.
Most bot logic should go in Hub.
Load config and set up necessary attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
game_step_override |
Optional[int]
|
If provided, set the game_step to this value regardless of how it was specified elsewhere |
None
|
Source code in src/ares/main.py
mediator
property
¶
Register behavior.
Shortcut to self.manager_hub.manager_mediator
Returns:
Type | Description |
---|---|
ManagerMediator
|
|
get_build_structures ¶
get_build_structures(
structure_unit_types,
unit_type,
build_dict=None,
ignored_build_from_tags=None,
)
Get all structures (or units) where we can spawn unit_type. Takes into account techlabs and reactors. And Gateway / warp gate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
structure_unit_types |
set[UnitTypeId]
|
The valid build structures we can spawn this unit_type from. |
required |
unit_type |
UnitTypeId
|
The target unit we are trying to spawn. |
required |
build_dict |
dict[Unit, UnitTypeId](optional)
|
Use to prevent selecting idle build structures that have already got a pending order this frame. Key: Unit that should get order, value: what UnitID to build |
None
|
ignored_build_from_tags |
Set[int]
|
Pass in if you don't want certain build structures selected. |
None
|
Returns:
Type | Description |
---|---|
list[Unit] :
|
List of structures / units where this unit could possibly be spawned from. |
Source code in src/ares/main.py
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
|
on_before_start
async
¶
Train a drone and split workers before managers are set up
Called before bot properly initializes
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_building_construction_complete
async
¶
On structure completion event (own units)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Unit
|
The Unit that just finished building |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_building_construction_started
async
¶
On structure starting
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Unit
|
|
required |
Returns:
Type | Description |
---|---|
None
|
|
on_end
async
¶
Output game info to the log and save data (if enabled)
Called on game end
Parameters:
Name | Type | Description | Default |
---|---|---|---|
game_result |
Result
|
The game result |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_start
async
¶
Set up game step, managers, and information that requires game data
Called just before the first step, all game info is available
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_step
async
¶
Play the game
Called on every game step
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iteration |
int
|
The current game iteration |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_unit_created
async
¶
On unit created event (own units)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Unit
|
The Unit that was just created |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_unit_destroyed
async
¶
On unit or structure destroyed event
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit_tag |
int
|
The tag of the unit that was just destroyed |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
on_unit_took_damage
async
¶
On unit or structure taking damage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit |
Unit
|
The Unit that took damage |
required |
amount_damage_taken |
float
|
The amount of damage the Unit took |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
register_behavior ¶
Register behavior.
Shortcut to self.behavior_executioner.register_behavior
Parameters:
Name | Type | Description | Default |
---|---|---|---|
behavior |
Behavior
|
Class that follows the Behavior interface. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
register_managers ¶
Register standard and custom managers.
Override in your bot class if you wish to use custom managers.
Examples:
custom_production_manager = CustomProductionManager( self, self.config, manager_mediator ) new_manager = NewManager(self, self.config, manager_mediator)
self.manager_hub = Hub( self, self.config, manager_mediator, production_manager=custom_production_manager, additional_managers=[new_manager], )
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/ares/main.py
structure_pending ¶
Checks pending structures, includes workers on route.
Alternative and faster version of self.already_pending
Parameters:
Name | Type | Description | Default |
---|---|---|---|
structure_type |
UnitTypeId
|
|
required |
Returns:
Type | Description |
---|---|
int
|
|
Source code in src/ares/main.py
structure_present_or_pending ¶
Checks presence of a structure, or if worker is on route to build structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
structure_type |
UnitTypeId
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in src/ares/main.py
unit_pending ¶
Checks pending units.
Alternative and faster version of self.already_pending
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit_type |
UnitTypeId
|
|
required |
Returns:
Type | Description |
---|---|
int
|
|