Skip to content

Commit

Permalink
Merge pull request #86 from DrInfy/remove_deprecated_acts
Browse files Browse the repository at this point in the history
Remove deprecated acts
  • Loading branch information
DrInfy authored Oct 16, 2020
2 parents 829b831 + fcef512 commit b18e715
Show file tree
Hide file tree
Showing 29 changed files with 24 additions and 239 deletions.
5 changes: 5 additions & 0 deletions dummies/protoss/cannon_rush.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sc2.unit import Unit

from sharpy.knowledges import KnowledgeBot, Knowledge
from sharpy.managers import ManagerBase
from sharpy.managers.building_solver import WallType
from sharpy.managers.roles import UnitTask
from sharpy.plans import BuildOrder, Step, SequentialList, StepBuildGas
Expand Down Expand Up @@ -192,6 +193,10 @@ def __init__(self, build_name: str = "default"):
super().__init__("Sharp Cannon")
self.build_name = build_name

def configure_managers(self) -> Optional[List[ManagerBase]]:
self.knowledge.roles.set_tag_each_iteration = True
return super().configure_managers()

async def create_plan(self) -> BuildOrder:
if self.build_name == "default":
rnd = select_build_index(self.knowledge, "build.cannonrush", 0, 2)
Expand Down
4 changes: 2 additions & 2 deletions sharpy/plans/acts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from .cancel_building import CancelBuilding
from .defensive_building import DefensePosition
from .defensive_building import DefensiveBuilding
from .expand import Expand, ActExpand
from .expand import Expand
from .grid_building import GridBuilding
from .methods import merge_to_act
from .morph_warp_gates import MorphWarpGates
from .position_building import PositionBuilding
from .reserve import Reserve
from .tech import Tech, ActTech
from .tech import Tech
from .workers import Workers
from .auto_worker import AutoWorker
6 changes: 0 additions & 6 deletions sharpy/plans/acts/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,3 @@ def expanding_in(self, zone: "Zone") -> bool:
return True

return False


class ActExpand(Expand):
def __init__(self, to_count: int, priority: bool = False, consider_worker_production: bool = True):
warnings.warn("'ActExpand' is deprecated, use 'Expand' instead", DeprecationWarning, 2)
super().__init__(to_count, priority, consider_worker_production)
9 changes: 3 additions & 6 deletions sharpy/plans/acts/protoss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from .archon import Archon, ActArchon
from .archon import Archon
from .artosis_pylon import ArtosisPylon
from .auto_pylon import AutoPylon
from .chrono_any_tech import ChronoAnyTech
from .chrono_tech import ChronoTech
from .chrono_unit import ChronoUnit, ChronoUnitProduction
from .defensive_cannons import DefensiveCannons, ActDefensiveCannons
from .gate_unit import GateUnit
from .chrono_unit import ChronoUnit
from .defensive_cannons import DefensiveCannons
from .protoss_unit import ProtossUnit
from .restore_power import RestorePower
from .robo_unit import RoboUnit
from .star_unit import StarUnit
from .warp_unit import WarpUnit
from .chrono_building import ChronoBuilding
6 changes: 0 additions & 6 deletions sharpy/plans/acts/protoss/archon.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,3 @@ async def execute(self) -> bool:
def on_unit_destroyed(self, event: UnitDestroyedEvent):
if event.unit_tag in self.already_merging_tags:
self.already_merging_tags.remove(event.unit_tag)


class ActArchon(Archon):
def __init__(self, allowed_types: List[UnitTypeId]):
warnings.warn("'ActArchon' is deprecated, use 'Archon' instead", DeprecationWarning, 2)
super().__init__(allowed_types)
6 changes: 0 additions & 6 deletions sharpy/plans/acts/protoss/chrono_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,3 @@ async def execute(self) -> bool:
self.casted += 1
return True # TODO: better solution for real time, to prevent multiple duplicate chronos
return True # Never block


class ChronoUnitProduction(ChronoUnit):
def __init__(self, name: UnitTypeId, from_building: UnitTypeId):
warnings.warn("'ChronoUnitProduction' is deprecated, use 'ChronoUnit' instead", DeprecationWarning, 2)
super().__init__(name, from_building)
6 changes: 0 additions & 6 deletions sharpy/plans/acts/protoss/defensive_cannons.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ def defense_position(self, zone: Zone, pylon: Unit):
return position.towards(target_pos, 3)

return position.towards(zone.center_location, -2)


class ActDefensiveCannons(DefensiveCannons):
def __init__(self, to_count_pre_base: int, additional_batteries: int = 0, to_base_index: Optional[int] = None):
warnings.warn("'ActDefensiveCannons' is deprecated, use 'DefensiveCannons' instead", DeprecationWarning, 2)
super().__init__(to_count_pre_base, additional_batteries, to_base_index)
36 changes: 0 additions & 36 deletions sharpy/plans/acts/protoss/gate_unit.py

This file was deleted.

18 changes: 0 additions & 18 deletions sharpy/plans/acts/protoss/robo_unit.py

This file was deleted.

18 changes: 0 additions & 18 deletions sharpy/plans/acts/protoss/star_unit.py

This file was deleted.

6 changes: 0 additions & 6 deletions sharpy/plans/acts/protoss/warp_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,3 @@ async def execute(self) -> bool:
cost = self.ai._game_data.calculate_ability_cost(unit.creation_ability)
self.knowledge.reserve(cost.minerals, cost.vespene)
return False


class ActWarpUnit(WarpUnit):
def __init__(self, unit_type: UnitTypeId, to_count: int = 9999, priority: bool = False):
warnings.warn("'ActWarpUnit' is deprecated, use 'WarpUnit' instead", DeprecationWarning, 2)
super().__init__(unit_type, to_count, priority)
6 changes: 0 additions & 6 deletions sharpy/plans/acts/tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,3 @@ def already_pending_upgrade(self, builders: Units) -> float:
return 0
return order.progress
return 0


class ActTech(Tech):
def __init__(self, upgrade_type: UpgradeId, from_building: UnitTypeId = None):
warnings.warn("'ActTech' is deprecated, use 'Tech' instead", DeprecationWarning, 2)
super().__init__(upgrade_type, from_building)
2 changes: 1 addition & 1 deletion sharpy/plans/acts/terran/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .build_addon import BuildAddon, ActBuildAddon
from .build_addon import BuildAddon
from .morph_orbitals import MorphOrbitals
from .morph_planetary import MorphPlanetary
from .terran_unit import TerranUnit
Expand Down
6 changes: 0 additions & 6 deletions sharpy/plans/acts/terran/build_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,3 @@ def get_count(self, unit_type: UnitTypeId) -> int:
count += self.cache.own(unit_type).amount

return count


class ActBuildAddon(BuildAddon):
def __init__(self, unit_type: UnitTypeId, unit_from_type: UnitTypeId, to_count: int):
warnings.warn("'ActBuildAddon' is deprecated, use 'BuildAddon' instead", DeprecationWarning, 2)
super().__init__(unit_type, unit_from_type, to_count)
24 changes: 12 additions & 12 deletions sharpy/plans/require/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from .require_base import RequireBase
from .require_custom import RequireCustom
from .any import Any, RequiredAny
from .all import All, RequiredAll
from .gas import Gas, RequiredGas
from .minerals import Minerals, RequiredMinerals
from .supply import Supply, RequiredSupply, SupplyType
from .supply_left import SupplyLeft, RequiredSupplyLeft
from .tech_ready import TechReady, RequiredTechReady
from .any import Any
from .all import All
from .gas import Gas
from .minerals import Minerals
from .supply import Supply, SupplyType
from .supply_left import SupplyLeft
from .tech_ready import TechReady
from .time import Time, RequiredTime
from .unit_exists import UnitExists, RequiredUnitExists
from .enemy_unit_exists import EnemyUnitExists, RequiredEnemyUnitExists
from .unit_ready import UnitReady, RequiredUnitReady
from .enemy_unit_exists_after import EnemyUnitExistsAfter, RequiredEnemyUnitExistsAfter
from .enemy_building_exists import EnemyBuildingExists, RequiredEnemyBuildingExists
from .unit_exists import UnitExists
from .enemy_unit_exists import EnemyUnitExists
from .unit_ready import UnitReady
from .enemy_unit_exists_after import EnemyUnitExistsAfter
from .enemy_building_exists import EnemyBuildingExists
from .count import Count
from .methods import merge_to_require
from .once import Once
10 changes: 0 additions & 10 deletions sharpy/plans/require/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,3 @@ def check(self) -> bool:
return False

return True


class RequiredAll(All):
def __init__(
self,
conditions: Union[RequireBase, Callable[["Knowledge"], bool], List[RequireBase]],
*args: Union[RequireBase, Callable[["Knowledge"], bool]]
):
warnings.warn("'RequiredAll' is deprecated, use 'All' instead", DeprecationWarning, 2)
super().__init__(conditions, *args)
10 changes: 0 additions & 10 deletions sharpy/plans/require/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,3 @@ def check(self) -> bool:
return True

return False


class RequiredAny(Any):
def __init__(
self,
conditions: Union[RequireBase, Callable[["Knowledge"], bool], List[RequireBase]],
*args: Union[RequireBase, Callable[["Knowledge"], bool]]
):
warnings.warn("'RequiredAny' is deprecated, use 'Any' instead", DeprecationWarning, 2)
super().__init__(conditions, *args)
8 changes: 0 additions & 8 deletions sharpy/plans/require/enemy_building_exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,3 @@ def check(self) -> bool:
return True

return False


class RequiredEnemyBuildingExists(EnemyBuildingExists):
def __init__(self, unit_type: UnitTypeId, count: int = 1):
warnings.warn(
"'RequiredEnemyBuildingExists' is deprecated, use 'EnemyBuildingExists' instead", DeprecationWarning, 2
)
super().__init__(unit_type, count)
6 changes: 0 additions & 6 deletions sharpy/plans/require/enemy_unit_exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ def check(self) -> bool:
return True

return False


class RequiredEnemyUnitExists(EnemyUnitExists):
def __init__(self, unit_type: UnitTypeId, count: int = 1):
warnings.warn("'RequiredEnemyUnitExists' is deprecated, use 'EnemyUnitExists' instead", DeprecationWarning, 2)
super().__init__(unit_type, count)
8 changes: 0 additions & 8 deletions sharpy/plans/require/enemy_unit_exists_after.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,3 @@ def check(self) -> bool:
return True

return False


class RequiredEnemyUnitExistsAfter(EnemyUnitExistsAfter):
def __init__(self, unit_type: UnitTypeId, count: int = 1):
warnings.warn(
"'RequiredEnemyUnitExistsAfter' is deprecated, use 'EnemyUnitExistsAfter' instead", DeprecationWarning, 2
)
super().__init__(unit_type, count)
6 changes: 0 additions & 6 deletions sharpy/plans/require/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ def check(self) -> bool:
if self.ai.vespene > self.vespene_requirement:
return True
return False


class RequiredGas(Gas):
def __init__(self, vespene_requirement: int):
warnings.warn("'RequiredGas' is deprecated, use 'Gas' instead", DeprecationWarning, 2)
super().__init__(vespene_requirement)
6 changes: 0 additions & 6 deletions sharpy/plans/require/minerals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ def check(self) -> bool:
if self.ai.minerals > self.mineralRequirement:
return True
return False


class RequiredMinerals(Minerals):
def __init__(self, mineral_requirement: int):
warnings.warn("'RequiredMinerals' is deprecated, use 'Minerals' instead", DeprecationWarning, 2)
super().__init__(mineral_requirement)
6 changes: 0 additions & 6 deletions sharpy/plans/require/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ def check(self) -> bool:
return self.ai.supply_used - self.ai.supply_workers >= self.supply_amount

return self.ai.supply_workers >= self.supply_amount


class RequiredSupply(Supply):
def __init__(self, supply_amount: int, supply_type: SupplyType = SupplyType.All):
warnings.warn("'RequiredSupply' is deprecated, use 'Supply' instead", DeprecationWarning, 2)
super().__init__(supply_amount, supply_type)
6 changes: 0 additions & 6 deletions sharpy/plans/require/supply_left.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ def check(self) -> bool:
if self.ai.supply_left <= self.supplyAmount and self.ai.supply_cap < 200:
return True
return False


class RequiredSupplyLeft(SupplyLeft):
def __init__(self, supply_amount: int):
warnings.warn("'RequiredSupplyLeft' is deprecated, use 'SupplyLeft' instead", DeprecationWarning, 2)
super().__init__(supply_amount)
6 changes: 0 additions & 6 deletions sharpy/plans/require/tech_ready.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,3 @@ def check(self) -> bool:
if self.ai.already_pending_upgrade(self.name) >= self.percentage:
return True
return False


class RequiredTechReady(TechReady):
def __init__(self, upgrade: UpgradeId, percentage: float = 1):
warnings.warn("'RequiredTechReady' is deprecated, use 'TechReady' instead", DeprecationWarning, 2)
super().__init__(upgrade, percentage)
13 changes: 0 additions & 13 deletions sharpy/plans/require/unit_exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,3 @@ def __init__(
def check(self) -> bool:
count = self.get_count(self.unit_type, self.include_pending, self.include_killed, self.include_not_ready)
return count >= self.count


class RequiredUnitExists(UnitExists):
def __init__(
self,
unit_type: UnitTypeId,
count: int = 1,
include_pending: bool = False,
include_killed: bool = False,
include_not_ready: bool = True,
):
warnings.warn("'RequiredUnitExists' is deprecated, use 'UnitExists' instead", DeprecationWarning, 2)
super().__init__(unit_type, count, include_pending, include_killed, include_not_ready)
6 changes: 0 additions & 6 deletions sharpy/plans/require/unit_ready.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,3 @@ def check(self) -> bool:

count += build_progress
return count >= self.count


class RequiredUnitReady(UnitReady):
def __init__(self, unit_type: UnitTypeId, count: float = 1):
warnings.warn("'RequiredUnitReady' is deprecated, use 'UnitReady' instead", DeprecationWarning, 2)
super().__init__(unit_type, count)
2 changes: 1 addition & 1 deletion sharpy/plans/tactics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from .worker_counterattack import WorkerCounterAttack
from .worker_rally_point import WorkerRallyPoint
from .scouting import Scout, ScoutLocation
from .distribute_workers import DistributeWorkers, PlanDistributeWorkers, PlanDistributeWorkersV2
from .distribute_workers import DistributeWorkers
12 changes: 0 additions & 12 deletions sharpy/plans/tactics/distribute_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,3 @@ def assign_to_work(self, worker: Unit, work: Unit):
self.do(worker.gather(work, queue=True))
else:
self.do(worker.gather(work))


class PlanDistributeWorkers(DistributeWorkers):
def __init__(self, *args, **kwargs):
warnings.warn("'PlanDistributeWorkers' is deprecated, use 'DistributeWorkers' instead", DeprecationWarning, 2)
super().__init__(*args, **kwargs)


class PlanDistributeWorkersV2(DistributeWorkers):
def __init__(self, *args, **kwargs):
warnings.warn("'PlanDistributeWorkersV2' is deprecated, use 'DistributeWorkers' instead", DeprecationWarning, 2)
super().__init__(*args, **kwargs)

0 comments on commit b18e715

Please sign in to comment.