Manager mediator
To enable communication between managers in ares-sc2, the mediator pattern is used internally. If you need to request
information or perform an action from a manager, it is strongly recommended that you do so through the mediator,
which can be accessed via self.mediator. For example:
Mediator concrete class is the single source of truth and coordinator of communications between the managers.
Source code in src/ares/managers/manager_mediator.py
get_air_avoidance_grid
property
¶
Get the air avoidance pathing grid. Any tile with a value greater than one will contain some dangerous effects or spells that should always be avoided. Such as storms, nukes, ravager biles etc...
GridManager
Example:
Returns:
| Type | Description |
|---|---|
ndarray
|
The air avoidance pathing grid. |
get_air_grid
property
¶
Get the air pathing grid.
Pathable tiles have a value of 1.0 Pathable tiles with enemy influence have a value > 1.0 The higher the value, the more influence there is. Non-pathable tiles have a value of np.inf
GridManager
Example:
Returns:
| Type | Description |
|---|---|
ndarray
|
The air pathing grid. |
get_air_vs_ground_grid
property
¶
Get the air vs ground pathing grid. (air grid)
grid is computed in a way that lowers the cost of nonpathable terrain for ground units, making air units naturally "drawn" to it.
Pathable tiles have a value of 1.0 Pathable tiles with enemy influence have a value > 1.0 The higher the value, the more influence there is. Non-pathable tiles have a value of np.inf
GridManager
Example:
Returns:
| Type | Description |
|---|---|
ndarray
|
The air vs ground pathing grid. |
get_all_enemy
property
¶
Get all enemy units.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
Units
|
All enemy units. |
get_banned_nydus_travellers
property
¶
Get the nydus travellers dictionary.
NydusManager
Returns:
| Type | Description |
|---|---|
dict[int, float]
|
Dictionary where key is unit tag, and value is info |
dict[int, float]
|
about the nydus travelers. |
get_building_counter
property
¶
Get a dictionary containing the number of each type of building in progress.
BuildingManager.
Returns:
| Type | Description |
|---|---|
defaultdict[UnitTypeId, int]
|
defaultdict[UnitTypeId, int]: Number of each type of UnitTypeId currently being tracked for building. |
get_building_tracker_dict
property
¶
Get the building tracker dictionary.
Building Manager.
Returns:
| Type | Description |
|---|---|
dict[int, dict[str, float | Point2 | Unit | UnitTypeId]]
|
dict[int, dict[str, float | Point2 | Unit | UnitTypeId]]: Tracks the worker tag to details such as the UnitTypeId of the building, the Point2 location for placement, the in-game time when the order started, and the purpose of the building. |
get_cached_enemy_army
property
¶
Get the Units object for the enemy army.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
Units
|
The enemy army. |
get_cached_enemy_workers
property
¶
Get the Units object for the enemy workers.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
Units
|
The enemy workers. |
get_cached_ground_grid
property
¶
get_climber_grid
property
¶
Get the climber ground pathing grid for reapers and colossus. Pathable tiles have a value of 1.0 Pathable tiles with enemy influence have a value > 1.0 The higher the value, the more influence there is. Non-pathable tiles have a value of np.inf
GridManager
Example:
Returns:
| Type | Description |
|---|---|
ndarray
|
The climber pathing grid. |
get_creep_coverage
property
¶
How much of the map is covered by creep?
CreepManager
Returns:
| Type | Description |
|---|---|
float
|
A float between 0.0 and 100.0 indicating the coverage of the map. |
get_creep_edges
property
¶
Fetches the edges of the detected creep on the map.
CreepManager
The returned value represents the creep edges in the form of NumPy arrays.
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple of numpy.ndarray A tuple containing two NumPy arrays. Reflecting the coordinates of the creep edges. |
get_creep_grid
property
¶
get_creep_tiles
property
¶
get_defensive_third
property
¶
Get the third furthest from enemy.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Location of the third base furthest from the enemy. |
get_did_enemy_rush
property
¶
Determines whether the enemy executed a rush strategy based on the intel manager's evaluation.
WARNING: Super opinionated!
Returns¶
bool True if the enemy performed a rush strategy, otherwise False.
get_enemy_army_dict
property
¶
Get the dictionary of enemy army unit types to the units themselves.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
defaultdict[UnitTypeId, list[Unit]]
|
The dictionary of enemy army unit types to the units themselves. |
get_enemy_expanded
property
¶
Has the enemy expanded?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Has enemy expanded out of their main? |
get_enemy_expansions
property
¶
Get the expansions, as ordered from the enemy's point of view.
TerrainManager
Returns:
| Type | Description |
|---|---|
list[tuple[Point2, float]]
|
list[tuple[Point2, float]]: The first element is the location of the base. The second element is the pathing distance from the enemy main base. |
get_enemy_fliers
property
¶
Get enemy flying units.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
Units
|
Enemy flying units. |
get_enemy_four_gate
property
¶
Has the enemy gone four gate?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Is enemy four gate? |
get_enemy_fourth
property
¶
Get the enemy fourth base.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Location of the enemy fourth base. |
get_enemy_ground
property
¶
Get enemy ground units.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
Units
|
Enemy ground units. |
get_enemy_has_base_outside_natural
property
¶
Has the enemy expanded outside their natural?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Has enemy expanded out of natural? |
get_enemy_ling_rushed
property
¶
Has the enemy ling rushed?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy ling rushed? |
get_enemy_main_nydus_points
property
¶
Get the optimal position for a nydus in enemy main, considering distance from base and ramp.
NydusManager
Returns:
| Type | Description |
|---|---|
list[Point2]
|
Potential nydus position. |
get_enemy_marauder_rush
property
¶
Is the enemy currently marauder rushing?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy marauder rush? |
get_enemy_marine_rush
property
¶
Is the enemy currently marine rushing?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy marine rushed? |
get_enemy_nat
property
¶
Get the enemy natural expansion.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Location of the enemy natural expansion. |
get_enemy_ramp
property
¶
Get the enemy main base ramp.
TerrainManager
Returns:
| Type | Description |
|---|---|
Ramp
|
sc2 Ramp object for the enemy main base ramp. |
get_enemy_ravager_rush
property
¶
Has the enemy ravager rushed?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy ravager rush? |
get_enemy_roach_rushed
property
¶
Did the enemy roach rush?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy roach rushed? |
get_enemy_third
property
¶
Get the enemy third base.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Location of the enemy third base. |
get_enemy_tree
property
¶
Get the KDTree representing all enemy unit positions.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
KDTree | None
|
KDTree representing all enemy unit positions. |
get_enemy_was_greedy
property
¶
Was the enemy greedy?
WARNING: Currently not working, will always return False
WARNING: Opinionated method, please write your own if you don't
agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy was greedy? |
get_enemy_went_four_gate
property
¶
The enemy went four gate this game?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy went four gate in this game? |
get_enemy_went_marauder_rush
property
¶
The enemy went marauder rush this game?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy went marauder rush in this game? |
get_enemy_went_marine_rush
property
¶
The enemy went marine rush this game?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy went marine rush in this game? |
get_enemy_went_reaper
property
¶
The enemy opened with reaper this game?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy went reaper in this game? |
get_enemy_worker_rushed
property
¶
The enemy went for a worker rush this game?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy went worker rush in this game? |
get_flying_enemy_near_bases
property
¶
Get a dictionary containing flying enemy near townhalls.
EnemyToBase Manager
Returns:
| Type | Description |
|---|---|
dict[int, set[int]]
|
dict[int, set[int]]: A dictionary mapping townhall tags (keys) to sets of enemy tags (values) near each base. |
get_flying_structure_tracker
property
¶
Get the current information stored by FlyingStructureManager.
FlyingStructureManager
Returns:
| Type | Description |
|---|---|
dict[int, Any]
|
Key -> structure_tag, Value -> Information about the flight. |
get_forcefield_positions
property
¶
get_gatekeeper_positions
property
¶
Get the gatekeeper positions dict.
PlacementManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expansion_location
|
Point2
|
Expansion location to check |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The expansion location and gatekeeper positions. |
get_ground_avoidance_grid
property
¶
Get the ground avoidance pathing grid. Any tile with a value greater than one will contain some dangerous effects or spells that should always be avoided. Such as storms, nukes, ravager biles etc...
GridManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The ground avoidance pathing grid. |
get_ground_enemy_near_bases
property
¶
Get a dictionary containing a ground enemy near townhalls.
EnemyToBase Manager
Returns:
| Type | Description |
|---|---|
dict[int, set[int]]
|
dict[int, set[int]]: A dictionary where the integer key is a townhall tag. And the value contains a set of ints containing enemy tags near this base. |
get_ground_grid
property
¶
Get the ground pathing grid. Pathable tiles have a value of 1.0 Pathable tiles with enemy influence have a value > 1.0 The higher the value, the more influence there is. Non-pathable tiles have a value of np.inf
GridManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The ground pathing grid. |
get_ground_to_air_grid
property
¶
Get an air grid that contains influence for ground dangers that can shoot air. This can be useful for keeping air units safe that can't attack ground units.
Pathable tiles have a value of 1.0 Pathable tiles with enemy influence have a value > 1.0 The higher the value, the more influence there is. Non-pathable tiles have a value of np.inf
GridManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The ground pathing grid. |
get_initial_pathing_grid
property
¶
Get the pathing grid as it was on the first iteration.
TerrainManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The pathing grid as it was on the first iteration. |
get_is_free_expansion
property
¶
Check all bases for a free expansion.
TerrainManager
Returns:
| Type | Description |
|---|---|
bool
|
True if there exists a free expansion, False otherwise. |
get_is_proxy_zealot
property
¶
There is currently a proxy zealot attempt from the enemy?
WARNING: Opinionated method, please write your own if you don't agree with this decision.
Intel Manager
Returns:
| Type | Description |
|---|---|
bool
|
Enemy is attempting a proxy zealot rush? |
get_main_air_threats_near_townhall
property
¶
Get the main enemy air force near one of our bases.
EnemyToBase Manager
Returns:
| Type | Description |
|---|---|
Units
|
The largest enemy air force near our bases. |
get_main_ground_threats_near_townhall
property
¶
Get the main enemy ground force near one of our bases.
EnemyToBase Manager
Returns:
| Type | Description |
|---|---|
Units
|
The largest enemy ground force near our bases. |
get_map_choke_points
property
¶
All the points on the map that compose choke points.
TerrainManager
Returns:
| Type | Description |
|---|---|
set[Point2]
|
All the points on the map that compose choke points. |
get_map_data_object
property
¶
Get the MapAnalyzer.MapData object being used.
PathManager
Returns:
| Type | Description |
|---|---|
MapData
|
The MapAnalyzer.MapData object being used. |
get_mineral_patch_to_list_of_workers
property
¶
Get a dictionary containing mineral tag to worker tags
Resource Manager
Returns:
| Type | Description |
|---|---|
dict[int, set[int]]
|
Dictionary where key is mineral tag, and value is workers assigned here. |
get_mineral_target_dict
property
¶
Get position in front of each mineral.
This position is used for speed mining, and is also useful for making sure worker is moved to the right side of a mineral.
ResourceManager
Returns:
| Type | Description |
|---|---|
dict[int, Point2]
|
Key -> mineral tag, Value -> Position |
get_num_available_mineral_patches
property
¶
Get the number available mineral fields.
An available mineral field is one that is near a townhall and has fewer than two assigned workers.
ResourceManager
Returns:
| Type | Description |
|---|---|
int
|
Number available mineral fields. |
get_nydus_travellers_dict
property
¶
Get the nydus travelers dictionary.
NydusManager
Returns:
| Type | Description |
|---|---|
dict[int, dict[str, int | Point2 | UnitTypeId]]
|
Dictionary where key is unit tag, and value is info |
dict[int, dict[str, int | Point2 | UnitTypeId]]
|
about the nydus travelers. |
get_ol_spot_near_enemy_nat
property
¶
Get the overlord spot nearest to the enemy natural.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Overlord spot near the enemy natural. |
get_ol_spots
property
¶
High ground Overlord hiding spots.
TerrainManager
Returns:
| Type | Description |
|---|---|
list[Point2]
|
|
get_old_own_army_dict
property
¶
Get the previous iteration's own_army dict.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
dict[UnitTypeId, list[Unit]]
|
The dictionary of own army unit types to the units themselves. |
get_own_army
property
¶
Get the Units object for our own army.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
Units
|
Our own army. |
get_own_army_dict
property
¶
Get the dictionary of own army unit types to the units themselves.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
dict[UnitTypeId, list[Unit]]
|
The dictionary of own army unit types to the units themselves. |
get_own_expansions
property
¶
Get the expansions.
TerrainManager
Returns:
| Type | Description |
|---|---|
list[tuple[Point2, float]]
|
list[tuple[Point2, float]]: |
get_own_nat
property
¶
Get our natural expansion.
TerrainManager
Returns:
| Type | Description |
|---|---|
Point2
|
Location of our natural expansion. |
get_own_structures_dict
property
¶
Get the dictionary of own structure types to the units themselves.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
defaultdict[UnitTypeId, list[Unit]]
|
The dictionary of own structure types to the units themselves. |
get_own_tree
property
¶
Get the KDTree representing all friendly unit positions.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
KDTree | None
|
KDTree representing all friendly unit positions. |
get_placements_dict
property
¶
Get the placement dict ares calculated at the beginning of the game.
Structure of dictionary:
base_loc is a Point2 key for every expansion location on map.
placement_dict = {
base_loc: Point2:
BuildingSize.TWO_BY_TWO: {
building_pos: Point2((2, 2)):
{
available: True,
has_addon: False
taken: False,
is_wall: True,
building_tag: 0,
worker_on_route: False,
time_requested: 0.0,
production_pylon: False,
bunker: False,
optimal_pylon: False
},
{...}
},
BuildingSize.THREE_BY_THREE: {
building_pos: Point2((5, 5)):
{
available: True,
has_addon: False
taken: False,
is_wall: True,
building_tag: 0,
worker_on_route: False,
time_requested: 0.0,
production_pylon: False,
bunker: False,
optimal_pylon: False
},
{...}
},
{...}
}
PlacementManager
Returns:
| Type | Description |
|---|---|
dict
|
Indicating if structure can be placed at given position. |
get_positions_blocked_by_burrowed_enemy
property
¶
Build positions that are blocked by a burrowed enemy unit.
TerrainManager
Returns:
| Type | Description |
|---|---|
list[Point2]
|
|
get_primary_nydus_enemy_main
property
¶
Get the optimal position for a nydus in the enemy main, considering distance from base and ramp.
Nydus Manager
Returns:
| Type | Description |
|---|---|
Point2
|
Potential nydus position. |
get_primary_nydus_own_main
property
¶
Get the optimal position for a nydus in the own main. Could be a useful scouting position.
Nydus Manager
Returns:
| Type | Description |
|---|---|
Point2
|
Potential nydus position. |
get_priority_ground_avoidance_grid
property
¶
Get the pathing grid containing things ground units should always avoid.
GridManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The priority ground avoidance pathing grid. |
get_pvz_nat_gatekeeping_pos
property
¶
Get the gatekeeper position in a PvZ natural wall if available.
WARNING: This can return None so your code should account for this.
PlacementManager
Returns:
| Type | Description |
|---|---|
Point2 | None
|
Position of gatekeeper in natural wall |
get_removed_units
property
¶
Get the units removed from memory units.
UnitCacheManager
Returns:
| Type | Description |
|---|---|
Units
|
The units removed from memory units. |
get_tactical_ground_grid
property
¶
Get the tactical ground grid.
Normal pathable tiles with no units on them have a value of 200.0
Tiles with more enemy have value > 200.0 Tiles with more friendly have value < 200.0
GridManager
Returns:
| Type | Description |
|---|---|
ndarray
|
The ground tactical grid. |
get_th_tag_with_largest_ground_threat
property
¶
Get the tag of our townhall with the largest enemy ground force nearby.
WARNING: This will remember the townhall tag even if the enemy has gone.
Do not use this to detect the enemy at a base.
Use get_main_ground_threats_near_townhall
Or get_ground_enemy_near_bases instead
EnemyToBase Manager
Returns:
| Type | Description |
|---|---|
int
|
The largest enemy ground force near our bases. |
get_unit_role_dict
property
¶
Get the dictionary of UnitRole to the set of tags of units with that role.
UnitRoleManager
Returns:
| Type | Description |
|---|---|
dict[UnitRole, set[int]]
|
Dictionary of |
get_unit_to_ability_dict
property
¶
Get a dictionary containing unit tag, to ability frame cooldowns.
AbilityTrackerManager.
Returns:
| Type | Description |
|---|---|
dict[int, Any]
|
Unit tag to abilities and the next frame they can be casted. |
get_whole_map_array
property
¶
Get the list containing every point on the map.
GridManager
Notes¶
This does not return Point2s.
Returns:
| Type | Description |
|---|---|
list[list[int]]
|
Every point on the map. |
get_whole_map_tree
property
¶
Get the KDTree of all points on the map.
PathManager
Returns:
| Type | Description |
|---|---|
KDTree
|
KDTree of all points on the map. |
get_worker_tag_to_townhall_tag
property
¶
Get a dictionary containing worker tag to townhall tag. Where the townhall is the place where worker returns resources
Resource Manager
Returns:
| Type | Description |
|---|---|
dict[int, int]
|
Dictionary where key is worker tag, and value is townhall tag. |
get_worker_to_mineral_patch_dict
property
¶
Get a dictionary containing worker tag to mineral patch tag.
Resource Manager
Returns:
| Type | Description |
|---|---|
dict[int, int]
|
Dictionary where key is worker tag, and value is mineral tag. |
get_worker_to_vespene_dict
property
¶
Get a dictionary containing worker tag to gas building tag.
Resource Manager
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary where key is worker tag, and value is gas building tag. |
should_calculate_tumor_spread
property
¶
Check whether the expensive tumor spread search should run this frame.
add_managers ¶
Generate manager dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
managers
|
list['Manager']
|
|
required |
Source code in src/ares/managers/manager_mediator.py
add_to_nydus_travellers ¶
Add a unit to the nydus travelers.
NydusManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
Unit The unit to be added to the nydus travellers. |
required | |
entry_nydus_tag
|
int The tag of the nydus we are entering. |
required | |
exit_nydus_tag
|
int The tag of the nydus we are exiting. |
required | |
exit_towards
|
Point2 The direction out of the exit nydus. |
required |
Source code in src/ares/managers/manager_mediator.py
assign_role ¶
Assign a unit a role.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
int
|
Tag of the unit to be assigned. |
required |
role
|
UnitRole
|
What role the unit should have. |
required |
remove_from_squad
|
bool
|
Attempt to remove this unit from squad bookkeeping. Default is True. |
required |
Source code in src/ares/managers/manager_mediator.py
batch_assign_role ¶
Assign a given role to a list of unit tags.
Nothing more than a for loop, provided for convenience.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
set[int]
|
Tags of the units to assign to a role. |
required |
role
|
UnitRole
|
The role the units should be assigned to. |
required |
Source code in src/ares/managers/manager_mediator.py
build_with_specific_worker ¶
Build a structure with a specific worker.
BuildingManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker
|
Unit
|
The chosen worker. |
required |
structure_type
|
UnitTypeId
|
What type of structure to build. |
required |
pos
|
Point2
|
Where the structure should be placed. |
required |
building_purpose
|
BuildingPurpose
|
Why the structure is being placed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if a position for the building is found and |
bool
|
the worker is valid, otherwise False. |
Source code in src/ares/managers/manager_mediator.py
building_position_blocked_by_burrowed_unit ¶
See if the building position is blocked by a burrowed unit.
TerrainManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker_tag
|
int
|
The worker attempting to build the structure. |
required |
position
|
Point2
|
Where the structure is attempting to be placed. |
required |
Returns:
| Type | Description |
|---|---|
Point2 | None
|
The position that's blocked by an enemy unit. |
Source code in src/ares/managers/manager_mediator.py
can_place_structure ¶
Check if the structure can be placed at a given position.
Faster cython alternative to python-sc2 await self.can_place()
PlacementManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Point2
|
The intended building position. |
required |
structure_type
|
UnitTypeId
|
Structure type we want to place. |
required |
include_addon
|
bool
|
For Terran structures, check addon will place too. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Indicating if the structure can be placed at a given position. |
Source code in src/ares/managers/manager_mediator.py
can_win_fight ¶
Get the predicted engagement result between two forces.
Combat Sim Manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
own_units
|
Units
|
Our units involved in the battle. |
required |
enemy_units
|
Units
|
The enemy units. |
required |
timing_adjust
|
bool
|
Whether to consider the distance between units. |
required |
good_positioning
|
bool
|
Whether to assume units are decently split. |
required |
workers_do_no_damage
|
bool
|
Whether to ignore workers' damage. |
required |
Returns:
| Type | Description |
|---|---|
EngagementResult
|
Enum indicating the human-readable engagement result. |
Source code in src/ares/managers/manager_mediator.py
cancel_structure ¶
Cancel a structure and remove from internal ares' bookkeeping.
If you try cancelling without calling this method, ares may try to keep rebuilding the canceled structure.
BuildingManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
Unit
|
The actual structure to cancel. |
required |
Source code in src/ares/managers/manager_mediator.py
clear_nydus_travellers ¶
Clear the nydus travelers dictionary.
NydusManager
Source code in src/ares/managers/manager_mediator.py
clear_role ¶
Clear a unit's role.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
int
|
Tag of the unit to clear the role of. |
required |
Source code in src/ares/managers/manager_mediator.py
find_closest_safe_spot ¶
Find the closest point with the lowest cost on a grid.
PathManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_pos
|
Point2
|
Where the search starts from. |
required |
grid
|
ndarray
|
The grid to find the low-cost point on. |
required |
radius
|
float
|
How far away the safe point can be. |
required |
Returns:
| Type | Description |
|---|---|
Point2
|
The closest location with the lowest cost. |
Source code in src/ares/managers/manager_mediator.py
find_low_priority_path ¶
Find several points in a path.
This way a unit can queue them up all at once for performance reasons.
i.e. running drones from a base or sending an overlord to a new position.
This does not return every point in the path. Instead, it returns points spread along the path.
PathManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Point2
|
Start point of the path. |
required |
target
|
Point2
|
Desired end point of the path. |
required |
grid
|
ndarray
|
The grid that should be used for pathing. |
required |
Returns:
| Type | Description |
|---|---|
list[Point2]
|
|
Source code in src/ares/managers/manager_mediator.py
find_lowest_cost_points ¶
Find the point(s) with the lowest cost within radius from from_pos.
PathManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_pos
|
Point2
|
Point to start the search from. |
required |
radius
|
float
|
How far away the returned points can be. |
required |
grid
|
ndarray
|
Which grid to query for lowest cost points. |
required |
Returns:
| Type | Description |
|---|---|
list[Point2]
|
Points with the lowest cost on the grid. |
Source code in src/ares/managers/manager_mediator.py
find_nearby_creep_edge_position ¶
Find the nearest position on the edge of the creep nearby a given point.
This function is used to determine a position that lies at the edge of the creep, close to a reference point within a game map scenario. The edge of the creep refers to the boundary or border of an area covered by creep, a terrain-modifying biome commonly associated with certain game mechanics.
Parameters¶
position : Point2
Where to search from
search_radius: float
How far to search for creep edge position.
closest_valid: bool
If True find the closest valid edge tile from position.
Else find the furthest
Default is True.
spread_dist: float
How much distance between existing tumors?
Default is 4.0
unit_tag : int | None, optional
Unit tag to check if queen ability is available, by default None
cache_result : bool, optional
Should we cache the result to save computation?
unit_tag should be set if this is True
by default False
Returns¶
Point2 | None The coordinates of the nearest position at the edge of the creep.
Source code in src/ares/managers/manager_mediator.py
find_nydus_at_location ¶
Given a location, find a potential nydus canal placement. Tries to avoid enemy visibility. Prioritizes locations that are already visible. Passing in a base location is recommended. But any position should work.
This only gives an idea where to place a nydus canal.
You still need to calculate a valid building placement, which might mean the actual valid canal location is slightly different.
This calculates placements out of vision if needed, so you
may need to send a scout before the canal can be placed.
Find a Nydus position with pathing cost less than max_cost in a region containing the given point, at least min_distance from an enemy base, and no more than max_distance from the target point.
NydusManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_location
|
Point2 |
required | |
min_base_distance
|
float |
required | |
max_nydus_distance
|
float |
required | |
max_cost
|
int |
required |
Returns:
| Type | Description |
|---|---|
Point2 | None
|
May return a location to be used for a nydus canal. |
Point2 | None
|
Could return None. |
Source code in src/ares/managers/manager_mediator.py
find_nydus_path_next_point ¶
Find the next point in a path including via nyduses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Point2
|
Start point of the path. |
required |
target
|
Point2
|
Desired end point of the path. |
required |
grid
|
ndarray
|
The grid that should be used for pathing. |
required |
sensitivity
|
int
|
Amount of points that should be skipped in the full path between tiles that are returned. Default value is 5. |
required |
smoothing
|
bool
|
Optional path smoothing where nodes are removed if it's possible to jump ahead some tiles in a straight line with a lower cost. Default value is False. |
required |
sense_danger
|
bool
|
Check to see if there are any dangerous tiles near the starting point. If this is True and there are no dangerous tiles near the starting point, the pathing query is skipped and the target is returned. Default value is True. |
required |
danger_distance
|
float
|
How far away from the start to look for danger. Default value is 20. |
required |
danger_threshold
|
float
|
Minimum value for a tile to be considered dangerous. Default value is 5. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point2 | None, Point2 | None, list[int] | None]
|
Tuple of (next_point, nydus_next_point, nydus_points) |
Source code in src/ares/managers/manager_mediator.py
find_path_next_point ¶
Find the next point in a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Point2
|
Start point of the path. |
required |
target
|
Point2
|
Desired end point of the path. |
required |
grid
|
ndarray
|
The grid that should be used for pathing. |
required |
sensitivity
|
int
|
Amount of points that should be skipped in the full path between tiles that are returned. Default value is 5. |
required |
smoothing
|
bool
|
Optional path smoothing where nodes are removed if it's possible to jump ahead some tiles in a straight line with a lower cost. Default value is False. |
required |
sense_danger
|
bool
|
Check to see if there are any dangerous tiles near the starting point. If this is True and there are no dangerous tiles near the starting point, the pathing query is skipped and the target is returned. Default value is True. |
required |
danger_distance
|
float
|
How far away from the start to look for danger. Default value is 20. |
required |
danger_threshold
|
float
|
Minimum value for a tile to be considered dangerous. Default value is 5. |
required |
Returns:
| Type | Description |
|---|---|
Point2
|
The next point in the path from the start to the target which may be the |
Point2
|
same as the target if it's safe. |
Source code in src/ares/managers/manager_mediator.py
find_raw_path ¶
Used for finding a full path, mostly for distance checks.
PathManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Point2
|
Start point of the path. |
required |
target
|
Point2
|
Desired end point of the path. |
required |
grid
|
ndarray
|
The grid that should be used for pathing. |
required |
sensitivity
|
int
|
Amount of points that should be skipped in the full path between tiles that are returned. |
required |
Returns:
| Type | Description |
|---|---|
list[Point2]
|
|
Source code in src/ares/managers/manager_mediator.py
get_all_from_roles_except ¶
Get all units from the given roles except for unit types in excluded.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
set[UnitRole]
|
Roles to get units from. |
required |
excluded
|
set[UnitTypeId]
|
Unit types that should not be included. |
required |
Returns:
| Type | Description |
|---|---|
Units
|
Units matching the role that are not of an excluded type. |
Source code in src/ares/managers/manager_mediator.py
get_any_enemies_in_range ¶
Check various positions for any enemy units in range.
UnitMemoryManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
list[Point2] |
required | |
radius
|
float |
required |
Returns:
| Type | Description |
|---|---|
list[bool]
|
list of bool for each position |
list[bool]
|
True would mean something is there |
Source code in src/ares/managers/manager_mediator.py
get_behind_mineral_positions ¶
Finds 3 spots behind the mineral line
This is useful for building structures out of typical cannon range.
TerrainManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
th_pos
|
Point2
|
Position of townhall to find points behind the mineral line of. |
required |
Returns:
| Type | Description |
|---|---|
list[Point2]
|
Points behind the mineral line of the designated base. |
Source code in src/ares/managers/manager_mediator.py
get_closest_creep_tile ¶
Get the closest creep tile to pos
WARNING: May return None if no creep tiles observed.
CreepManager
Example:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
Point2
|
The position to search for the closest creep tile. |
required |
Returns:
| Type | Description |
|---|---|
None | Point2
|
Point2 representing the closest creep tile or None if no creep tiles. |
Source code in src/ares/managers/manager_mediator.py
get_closest_overlord_spot ¶
Given a position, find the closest high ground overlord spot.
TerrainManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_pos
|
Point2
|
Position the Overlord spot should be closest to. |
required |
Returns:
| Type | Description |
|---|---|
Point2
|
The closest Overlord hiding spot to the position. |
Source code in src/ares/managers/manager_mediator.py
get_flood_fill_area ¶
Given a point, flood fill outward from it and return the valid points.
This flood fill does not continue through chokes.
TerrainManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_point
|
Point2
|
Where to start the flood fill. |
required |
max_dist
|
float
|
Only include points closer than this distance to the start point. |
required |
Returns:
| Type | Description |
|---|---|
set[tuple[int, int]]
|
tuple[int, list[tuple[int, int]]]: First element is the number of valid points. Second element is the list of all valid points. |
Source code in src/ares/managers/manager_mediator.py
get_is_detected ¶
Get if the enemy currently is revealing a cloaked or burrowed unit.
UnitMemoryManager
Returns:
| Type | Description |
|---|---|
bool
|
Boolean if unit is detected. |
Source code in src/ares/managers/manager_mediator.py
get_next_tumor_on_path ¶
Determines the next tumor position on the path, using vectorized operations to find positions along the creep edge that maintain proper separation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
np.ndarray A 2D array to path on. |
required | |
from_pos
|
Point2 The starting position from which the path is evaluated. |
required | |
to_pos
|
Point2 The target position on the grid where the path leads. |
required | |
max_distance
|
float, optional
The maximum allowable distance from the |
required | |
min_distance
|
float, optional
The minimum allowable distance from the |
required | |
min_separation
|
float, optional The minimum distance required between the new tumor and existing tumors/queen routes. Default is 3.0. |
required | |
find_alternative
|
bool, optional Find an alternative position if the closest position is too close to existing tumors Switch to False if possible to avoid unnecessary checks. Default is True. |
required |
Returns:
| Type | Description |
|---|---|
Point2 | None
|
Point2 or None Returns the next suitable tumor position on the grid if a valid position is found within the specified conditions. Returns None if no valid position exists. |
Source code in src/ares/managers/manager_mediator.py
get_overlord_creep_spotter_positions ¶
Find optimal positions for overlords to provide vision for creep spread.
This function finds the edge of the creep and distributes overlord positions evenly around it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlords
|
Units | list[Unit] The overlords that will be positioned for creep vision |
required |
Returns:
| Type | Description |
|---|---|
dict[int, Point2]
|
dict[int: Point2] Dictionary mapping overlord tag to position where it should move |
Source code in src/ares/managers/manager_mediator.py
get_own_unit_count ¶
Get the dictionary of own structure types to the units themselves.
UnitCacheManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_type_id
|
UnitTypeId
|
Unit type to count. |
required |
include_alias
|
bool
|
Check aliases. (default=True) |
required |
Returns:
| Type | Description |
|---|---|
int
|
Total count of this unit including aliases if specified. |
Source code in src/ares/managers/manager_mediator.py
get_position_blocks_expansion ¶
See if a position blocks an expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Point2 The position to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Position blocks expansion. |
Source code in src/ares/managers/manager_mediator.py
get_position_of_main_squad ¶
Given a unit role, find where the main squad is.
SquadManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
UnitRole
|
Get the squads for this unit role. |
required |
Returns:
| Type | Description |
|---|---|
Point2
|
Position of main squad for this |
Source code in src/ares/managers/manager_mediator.py
get_random_creep_position ¶
Find a random valid creep position within the tumor range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Point2 The position to search from. |
required | |
max_attempts
|
int Maximum attempts to find a valid position. |
required |
Returns:
| Type | Description |
|---|---|
Point2 | None
|
Point2 | None Random creep position. |
Source code in src/ares/managers/manager_mediator.py
get_squads ¶
Given a unit role, get the updated squads.
SquadManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
UnitRole
|
Get the squads for this unit role. |
required |
squad_radius
|
The threshold as to which separate squads are formed. |
required | |
unit_type
|
If specified, only form squads with these unit types WARNING: Will not remove units that have already been assigned to a squad. |
required |
Returns:
| Type | Description |
|---|---|
list[UnitSquad]
|
Each squad with this unit role. |
Source code in src/ares/managers/manager_mediator.py
get_tumor_influence_lowest_cost_position ¶
Determines the lowest cost position influenced by the tumor through a request to the creep manager.
This method sends a request to the creep manager to retrieve the position with the lowest cost under tumor influence. The operation is executed via the manager_request function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Point2 Tumor position. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Point2 |
Point2 | None
|
Furthest placement with the lowest cost under tumor influence. |
Source code in src/ares/managers/manager_mediator.py
get_units_from_role ¶
Get a Units object containing units with a given role.
If a UnitTypeId or set of UnitTypeIds are given, it will only return units of
those types, otherwise it will return all units with the role. If restrict_to
is specified, it will only retrieve units from that object.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
UnitRole
|
Role to get units from. |
required |
unit_type
|
UnitTypeId
|
Type(s) of units that should be returned. If omitted, all units with the role will be returned. |
required |
restrict_to
|
set[UnitTypeId]
|
If supplied, only take Units with the given role and type if they also exist here. |
required |
Returns:
| Type | Description |
|---|---|
Units
|
Units with the given role. |
Source code in src/ares/managers/manager_mediator.py
get_units_from_roles ¶
Get the units matching unit_type from the given roles.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
set[UnitRole]
|
Roles to get units from. |
required |
unit_type
|
UnitTypeId
|
Type(s) of units that should be returned. If omitted, all units with the role will be returned. |
required |
Returns:
| Type | Description |
|---|---|
Units
|
Units with the given roles. |
Source code in src/ares/managers/manager_mediator.py
get_units_from_tags ¶
Get a list of Unit objects corresponding to the given tags.
UnitCacheManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Tags of the units to retrieve. |
required |
Source code in src/ares/managers/manager_mediator.py
get_units_in_range ¶
Get units in range of other units or points.
UnitMemoryManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_points
|
List[Union[Unit, Tuple[float, float]]]
|
List of |
required |
distances
|
Union[float, List[float]]
|
How far away from each point to
query. Must broadcast to the length of |
required |
query_tree
|
UnitTreeQueryType
|
Which KDTree should be queried. |
required |
return_as_dict
|
bool
|
Sets whether the returned units in range should be a dictionary or list. Default is False. |
required |
Returns:
| Type | Description |
|---|---|
dict[int | tuple[float, float], Units] | list[Units]
|
Union[Dict[Union[int, Tuple[float, float]], Units], List[Units]]:
Returns the units in range of each start point as a |
Source code in src/ares/managers/manager_mediator.py
is_position_safe ¶
Check if the given position is considered dangerous.
PathManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
ndarray
|
The grid to evaluate safety on. |
required |
position
|
Point2
|
The position to check the safety of. |
required |
weight_safety_limit
|
float
|
The maximum value the point can have on the grid to be considered safe. Default value is 1.0. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the position is considered safe, False otherwise. |
Source code in src/ares/managers/manager_mediator.py
make_placement_available ¶
Make a placement available again.
PlacementManager
Parameters¶
size : The building size. base_location : Expansion location this placement is near. building_pos : Unique building placement. tag : optional Tag of existing structure.
Source code in src/ares/managers/manager_mediator.py
manager_request ¶
Function to request information from a manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
receiver
|
ManagerName
|
Manager receiving the request. |
required |
request
|
ManagerRequestType
|
Requested attribute/function call. |
required |
reason
|
str | None
|
Why the request is being made. |
None
|
kwargs
|
Keyword arguments (if any) to be passed to the requested function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
There are too many possible return types to list all of them. |
Source code in src/ares/managers/manager_mediator.py
move_structure ¶
Request a structure to move via flight.
FlyingStructureManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
Unit
|
The structure to be moved or landed. |
required |
target
|
Point2
|
The target location for the structure. |
required |
should_land
|
bool
|
Whether the structure should land after moving. Defaults to False. |
required |
Source code in src/ares/managers/manager_mediator.py
remove_from_nydus_travellers ¶
Remove a unit from the nydus travelers dictionary.
NydusManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_tag
|
int The unit tag to be removed from the nydus travelers. |
required |
Source code in src/ares/managers/manager_mediator.py
remove_gas_building ¶
Request for a gas building to be removed from bookkeeping.
Resource Manager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas_building_tag
|
int
|
The tag of the gas building to remove. |
required |
Source code in src/ares/managers/manager_mediator.py
remove_mineral_field ¶
Request for a mineral field to be removed from bookkeeping.
Resource Manager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mineral_field_tag
|
int
|
The tag of the mineral patch to remove. |
required |
Source code in src/ares/managers/manager_mediator.py
remove_tag_from_squads ¶
SquadManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
int
|
Get the squads for this unit role. |
required |
squad_radius
|
float
|
The threshold as to which separate squads are formed. |
required |
unit_type
|
UnitTypeId
|
If specified, only form squads with these unit types WARNING: Will not remove units that have already been assigned to a squad. |
required |
Returns:
| Type | Description |
|---|---|
None
|
Each squad with this unit role. |
Source code in src/ares/managers/manager_mediator.py
remove_worker_from_mineral ¶
Remove worker from internal data structures.
This happens if worker gets assigned to do something else
ResourceManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker_tag
|
Tag of the worker to be removed. |
required |
Source code in src/ares/managers/manager_mediator.py
request_building_placement ¶
Request a building placement from the precalculated building formation.
PlacementManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_location
|
Point2
|
The general area where the placement should be near. This should be an expansion location. |
required |
structure_type
|
UnitTypeId
|
Structure type requested. |
required |
first_pylon
|
bool
|
Try to take designated first pylon if available. Default value is False. |
required |
static_defence
|
bool
|
Try to take designated static defense placements if available. Default value is False. |
required |
wall
|
bool
|
Request a wall structure placement. Will find alternative if no wall placements available. Default value is False. |
required |
find_alternative
|
bool
|
If no placements available at base_location, find an alternative at a nearby base. Default value is True. |
required |
reserve_placement
|
bool
|
Reserve this booking for a while, so another customer doesn't request it. Default value is True. |
required |
within_psionic_matrix
|
bool
|
Protoss specific -> calculated position have power? Default value is False. |
required |
pylon_build_progress
|
float
|
Only relevant
if |
required |
closest_to
|
Point2
|
Find placement at base closest to this. |
required |
Returns:
| Type | Description |
|---|---|
Point2 | None
|
Indicating if structure can be placed at given position. |
Source code in src/ares/managers/manager_mediator.py
request_warp_in ¶
Request a warp in spot, without making a query to the game client.
PlacementManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_type
|
UnitTypeId
|
The unit we want to warp in. |
required |
target
|
Point2 | None
|
If provided, attempt to find spot closest to this location. |
required |
Source code in src/ares/managers/manager_mediator.py
select_worker ¶
Select a worker via the ResourceManager.
This way we can select one assigned to a far mineral patch. Make sure to change the worker role once selected, otherwise it will be selected to mine again. This doesn't select workers from geysers, so make sure to remove workers from gas if low on workers.
ResourceManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_position
|
Point2
|
Location to get the closest workers to. |
required |
force_close
|
bool
|
Select the available worker closest to
|
required |
select_persistent_builder
|
bool
|
If True, we can select the persistent_builder if it's available. |
required |
only_select_persistent_builder
|
bool
|
If True, don't find an alternative worker. |
required |
min_health_perc
|
float
|
Only select workers above this health percentage. |
required |
min_shield_perc
|
float
|
Only select workers above this shield percentage. |
required |
Returns:
| Type | Description |
|---|---|
Unit | None
|
Selected worker, if available. |
Source code in src/ares/managers/manager_mediator.py
set_workers_per_gas ¶
Give all units in a role a different role.
ResourceManager
Parameters¶
amount (int): Num workers to assign to each gas building
Source code in src/ares/managers/manager_mediator.py
switch_roles ¶
Give all units in a role a different role.
UnitRoleManager
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_role
|
UnitRole
|
Role the units currently have. |
required |
to_role
|
UnitRole
|
Role to assign to the units. |
required |
Source code in src/ares/managers/manager_mediator.py
update_unit_to_ability_dict ¶
Update tracking to reflect ability usage.
After a unit uses an ability, it should call this to update the frame the ability will next be available
AbilityTrackerManager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ability
|
AbilityId
|
The AbilityId that was used. |
required |
unit_tag
|
int
|
The tag of the Unit that used the ability. |
required |