Skip to content

Commit

Permalink
style: clean up imports and format code consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
raspersc2 committed Feb 17, 2025
1 parent db418f8 commit e6c3fa8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/ares/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from sc2.ids.effect_id import EffectId
from sc2.ids.unit_typeid import UnitTypeId as UnitID


"""Strings"""
# general/config
ACTIVE_GRID: str = "ActiveGrid"
Expand Down
43 changes: 28 additions & 15 deletions src/ares/managers/grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
from typing import TYPE_CHECKING, Any, Dict, List

import numpy as np
from cython_extensions import cy_distance_to_squared
from map_analyzer import MapData
from sc2.ids.effect_id import EffectId
from sc2.ids.unit_typeid import UnitTypeId as UnitID
from sc2.position import Point2, Point3
from sc2.unit import Unit

from ares.consts import (
ACTIVE_GRID,
AIR,
Expand All @@ -26,6 +33,7 @@
DEBUG_OPTIONS,
EFFECTS,
EFFECTS_RANGE_BUFFER,
FEATURES,
GROUND,
GROUND_AVOIDANCE,
GROUND_COST,
Expand All @@ -43,22 +51,16 @@
SHOW_PATHING_COST,
STORM,
TACTICAL_GROUND,
TACTICAL_GROUND_GRID,
TOWNHALL_TYPES,
UNITS,
ManagerName,
ManagerRequestType, FEATURES, TACTICAL_GROUND_GRID,
ManagerRequestType,
)
from ares.dicts.unit_data import UNIT_DATA
from ares.dicts.weight_costs import WEIGHT_COSTS
from ares.managers.manager import Manager
from ares.managers.manager_mediator import IManagerMediator, ManagerMediator
from cython_extensions import cy_distance_to_squared
from map_analyzer import MapData
from sc2.ids.effect_id import EffectId
from sc2.ids.unit_typeid import UnitTypeId as UnitID
from sc2.position import Point2, Point3
from sc2.unit import Unit


if TYPE_CHECKING:
from ares import AresBot
Expand Down Expand Up @@ -152,7 +154,9 @@ def __init__(
ManagerRequestType.GET_PRIORITY_GROUND_AVOIDANCE_GRID: (
lambda kwargs: self.priority_ground_avoidance_grid
),
ManagerRequestType.GET_TACTICAL_GROUND_GRID: (lambda kwargs: self.tactical_ground_grid),
ManagerRequestType.GET_TACTICAL_GROUND_GRID: (
lambda kwargs: self.tactical_ground_grid
),
}

self.air_grid: np.ndarray = self.map_data.get_clean_air_grid()
Expand Down Expand Up @@ -183,7 +187,9 @@ def __init__(
self._cached_clean_ground_grid.copy()
)

self.tactical_ground_grid_enabled: bool = self.config[FEATURES][TACTICAL_GROUND_GRID]
self.tactical_ground_grid_enabled: bool = self.config[FEATURES][
TACTICAL_GROUND_GRID
]
# ensure grid exists so mediator request dont break
self.tactical_ground_grid: np.ndarray = self.map_data.get_pyastar_grid(
default_weight=200
Expand Down Expand Up @@ -246,16 +252,22 @@ async def update(self, iteration: int) -> None:
for option, (grid, threshold) in debug_cases.items():
if self.config[DEBUG_OPTIONS][ACTIVE_GRID] == option:
if option == TACTICAL_GROUND:
height: float = self.ai.get_terrain_z_height(self.ai.start_location)
height: float = self.ai.get_terrain_z_height(
self.ai.start_location
)
indices = np.where(grid != threshold)
for x, y in zip(indices[0], indices[1]): # Properly zip the x and y coordinates
for x, y in zip(
indices[0], indices[1]
): # Properly zip the x and y coordinates
pos: Point3 = Point3((x, y, height))
if grid[x, y] == np.inf:
val: int = 9999
else:
val: int = int(grid[x, y])
if val != 9999:
self.ai.client.debug_text_world(str(val), pos, (201, 168, 79), 13)
self.ai.client.debug_text_world(
str(val), pos, (201, 168, 79), 13
)
else:
self.map_data.draw_influence_in_game(
grid, lower_threshold=threshold
Expand Down Expand Up @@ -358,7 +370,9 @@ def reset_grids(self, iteration: int) -> None:
self.priority_ground_avoidance_grid = self._cached_clean_ground_grid.copy()
self.ground_to_air_grid = self._cached_clean_air_grid.copy()
if self.tactical_ground_grid_enabled:
self.tactical_ground_grid = self.map_data.get_pyastar_grid(default_weight=200)
self.tactical_ground_grid = self.map_data.get_pyastar_grid(
default_weight=200
)

# Refresh the cached ground grid every 8 steps, because things like structures/
# minerals / rocks will change throughout the game
Expand Down Expand Up @@ -398,7 +412,6 @@ def add_structure_influence(self, enemy: Unit) -> None:
if enemy.is_ready:
self._add_structure_influence(enemy)


def _add_effects(self) -> None:
"""Add effects influence to map."""
effect_values: Dict = self.config[PATHING][EFFECTS]
Expand Down
6 changes: 3 additions & 3 deletions src/ares/managers/manager_mediator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
)

import numpy as np
from ares.consts import EngagementResult, ManagerName, ManagerRequestType, UnitRole
from map_analyzer import MapData
from sc2.game_info import Ramp
from sc2.ids.unit_typeid import UnitTypeId as UnitID
Expand All @@ -24,6 +23,7 @@
from sc2.units import Units
from scipy.spatial import KDTree

from ares.consts import EngagementResult, ManagerName, ManagerRequestType, UnitRole

if TYPE_CHECKING:
from ares.managers.squad_manager import UnitSquad
Expand All @@ -45,7 +45,7 @@ def manager_request(
receiver: ManagerName,
request: ManagerRequestType,
reason: str = None,
**kwargs
**kwargs,
) -> Any:
"""How requests will be structured.
Expand Down Expand Up @@ -88,7 +88,7 @@ def manager_request(
receiver: ManagerName,
request: ManagerRequestType,
reason: str = None,
**kwargs
**kwargs,
) -> Any:
"""Function to request information from a manager.
Expand Down
1 change: 1 addition & 0 deletions src/ares/managers/path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PathManager(Manager, IManagerMediator):
All unit pathing should be done here
This also exposes SC2MapAnalyzer api_reference through `self.map_data`
"""

map_data: MapData

def __init__(
Expand Down

0 comments on commit e6c3fa8

Please sign in to comment.