diff --git a/bot_loader/bot_definitions.py b/bot_loader/bot_definitions.py index 21069981..6ed261e4 100644 --- a/bot_loader/bot_definitions.py +++ b/bot_loader/bot_definitions.py @@ -212,10 +212,14 @@ def func(params: List[str], tmp_path=full_path, path2=json_path): return bots def add_debug_bots(self, bot_dict: Dict[str, Tuple[Callable[[List[str]], AbstractPlayer], Optional[LadderZip]]]): - """ Debug bots won't have zip function. """ + """Debug bots won't have zip function.""" debug_bots = { - "debugidle": (lambda params: Bot(race_selector(BotDefinitions.index_check(params, 0, "random")), IdleDummy())), - "debugevade": (lambda params: Bot(race_selector(BotDefinitions.index_check(params, 0, "random")), EvadeDummy())), + "debugidle": ( + lambda params: Bot(race_selector(BotDefinitions.index_check(params, 0, "random")), IdleDummy()) + ), + "debugevade": ( + lambda params: Bot(race_selector(BotDefinitions.index_check(params, 0, "random")), EvadeDummy()) + ), "debugtemplate": (lambda params: Bot(Race.Zerg, TemplateSkeletonBot())), "debugunits": (lambda params: Bot(Race.Zerg, DebugUnitsDummy())), "debugrestorepower": (lambda params: Bot(Race.Protoss, RestorePowerDummy())), diff --git a/bot_loader/ladder_zip.py b/bot_loader/ladder_zip.py index ecfdbed8..64cd657d 100644 --- a/bot_loader/ladder_zip.py +++ b/bot_loader/ladder_zip.py @@ -92,11 +92,11 @@ def create_bin_json(self): return json_exe.replace("[NAME]", self.name).replace("[RACE]", self.race) def pre_zip(self): - """ Override this as needed, actions to do before creating the zip""" + """Override this as needed, actions to do before creating the zip""" pass def post_zip(self): - """ Override this as needed, actions to do after creating the zip""" + """Override this as needed, actions to do after creating the zip""" pass def package_executable(self, output_dir: str): diff --git a/bot_loader/runner.py b/bot_loader/runner.py index cfffae42..380e1b23 100644 --- a/bot_loader/runner.py +++ b/bot_loader/runner.py @@ -58,7 +58,7 @@ def run_game( result = asyncio.get_event_loop().run_until_complete( asyncio.gather( _host_game(map_settings, players, **kwargs, portconfig=portconfig), - self.join_game(ladder_bot, False, portconfig, opponent_id) + self.join_game(ladder_bot, False, portconfig, opponent_id), # ladder_bot.join_game(opponent_id, portconfig=portconfig) ) ) diff --git a/dummies/debug/evade_dummy.py b/dummies/debug/evade_dummy.py index 1018dbde..5e6b1427 100644 --- a/dummies/debug/evade_dummy.py +++ b/dummies/debug/evade_dummy.py @@ -13,6 +13,7 @@ from sharpy.plans import BuildOrder from sharpy.combat import Action, MoveType, GenericMicro, CombatModel + class MicroEvade(GenericMicro): def __init__(self): self.surround_move = False diff --git a/dummies/protoss/adept_allin.py b/dummies/protoss/adept_allin.py index 6a897d9d..ee9b233b 100644 --- a/dummies/protoss/adept_allin.py +++ b/dummies/protoss/adept_allin.py @@ -59,7 +59,8 @@ async def create_plan(self) -> BuildOrder: skip_until=UnitReady(UnitTypeId.GATEWAY, 1), ), Step( - UnitReady(UnitTypeId.CYBERNETICSCORE, 1), ProtossUnit(UnitTypeId.ADEPT, 2, only_once=True), + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + ProtossUnit(UnitTypeId.ADEPT, 2, only_once=True), ), Tech(UpgradeId.WARPGATERESEARCH), ProtossUnit(UnitTypeId.ADEPT, 100), @@ -69,7 +70,12 @@ async def create_plan(self) -> BuildOrder: GridBuilding(UnitTypeId.GATEWAY, 4), skip_until=Minerals(200), ), - Step(None, ProtossUnit(UnitTypeId.ZEALOT, 100), skip=Gas(25), skip_until=Minerals(200),), + Step( + None, + ProtossUnit(UnitTypeId.ZEALOT, 100), + skip=Gas(25), + skip_until=Minerals(200), + ), ), ), SequentialList( diff --git a/dummies/protoss/cannon_rush.py b/dummies/protoss/cannon_rush.py index 073d357b..0ec47e74 100644 --- a/dummies/protoss/cannon_rush.py +++ b/dummies/protoss/cannon_rush.py @@ -250,7 +250,10 @@ async def create_plan(self) -> BuildOrder: ], [ProtossUnit(UnitTypeId.STALKER, 100)], [ - Step(UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1),), + Step( + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), + ), Step(UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.GATEWAY, 7)), StepBuildGas(4, skip=Gas(200)), ], diff --git a/dummies/protoss/disruptor.py b/dummies/protoss/disruptor.py index f08adba2..6c60fdef 100644 --- a/dummies/protoss/disruptor.py +++ b/dummies/protoss/disruptor.py @@ -48,7 +48,10 @@ def __init__(self): GridBuilding(UnitTypeId.ROBOTICSFACILITY, 1, priority=True), Tech(UpgradeId.WARPGATERESEARCH, UnitTypeId.CYBERNETICSCORE), GridBuilding(UnitTypeId.ROBOTICSBAY, 1, priority=True), - Step(UnitExists(UnitTypeId.DISRUPTOR, 1, include_killed=True, include_not_ready=False), Expand(2),), + Step( + UnitExists(UnitTypeId.DISRUPTOR, 1, include_killed=True, include_not_ready=False), + Expand(2), + ), BuildGas(4), ), BuildOrder( diff --git a/dummies/protoss/gate4.py b/dummies/protoss/gate4.py index 86a8ec16..fd21a297 100644 --- a/dummies/protoss/gate4.py +++ b/dummies/protoss/gate4.py @@ -64,7 +64,10 @@ def create_plan(self) -> BuildOrder: AutoPylon(), ActUnit(UnitTypeId.PROBE, UnitTypeId.NEXUS, 22), SequentialList( - Step(UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1),), + Step( + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), + ), Step(UnitReady(UnitTypeId.TWILIGHTCOUNCIL, 1), Tech(UpgradeId.BLINKTECH)), ), SequentialList( @@ -74,7 +77,8 @@ def create_plan(self) -> BuildOrder: skip_until=UnitReady(UnitTypeId.GATEWAY, 1), ), Step( - UnitReady(UnitTypeId.CYBERNETICSCORE, 1), ProtossUnit(UnitTypeId.ADEPT, 2, only_once=True), + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + ProtossUnit(UnitTypeId.ADEPT, 2, only_once=True), ), Tech(UpgradeId.WARPGATERESEARCH), ProtossUnit(UnitTypeId.STALKER, 100), diff --git a/dummies/protoss/proxy_zealot_rush.py b/dummies/protoss/proxy_zealot_rush.py index d23ceab8..79185f65 100644 --- a/dummies/protoss/proxy_zealot_rush.py +++ b/dummies/protoss/proxy_zealot_rush.py @@ -196,7 +196,10 @@ async def create_plan(self) -> BuildOrder: StepBuildGas(5, skip=Gas(200)), ], SequentialList( - Step(UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1),), + Step( + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), + ), GridBuilding(UnitTypeId.STARGATE, 1), Step(UnitReady(UnitTypeId.TWILIGHTCOUNCIL, 1), Tech(UpgradeId.CHARGE)), Step(UnitReady(UnitTypeId.TWILIGHTCOUNCIL, 1), Tech(UpgradeId.ADEPTPIERCINGATTACK)), diff --git a/dummies/protoss/robo.py b/dummies/protoss/robo.py index b2de7250..a1a23957 100644 --- a/dummies/protoss/robo.py +++ b/dummies/protoss/robo.py @@ -59,7 +59,8 @@ async def create_plan(self) -> BuildOrder: SequentialList( [ Step( - UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), ), GridBuilding(UnitTypeId.ROBOTICSFACILITY, 1), Step(UnitReady(UnitTypeId.TWILIGHTCOUNCIL, 1), Tech(UpgradeId.CHARGE)), diff --git a/dummies/protoss/voidray.py b/dummies/protoss/voidray.py index ecee341a..f6b336a4 100644 --- a/dummies/protoss/voidray.py +++ b/dummies/protoss/voidray.py @@ -58,7 +58,8 @@ async def create_plan(self) -> BuildOrder: SequentialList( [ Step( - UnitReady(UnitTypeId.CYBERNETICSCORE, 1), GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), + UnitReady(UnitTypeId.CYBERNETICSCORE, 1), + GridBuilding(UnitTypeId.TWILIGHTCOUNCIL, 1), ), GridBuilding(UnitTypeId.STARGATE, 1), Step(UnitReady(UnitTypeId.TWILIGHTCOUNCIL, 1), Tech(UpgradeId.CHARGE)), diff --git a/dummies/terran/banshees.py b/dummies/terran/banshees.py index 622ab355..0971f25b 100644 --- a/dummies/terran/banshees.py +++ b/dummies/terran/banshees.py @@ -71,7 +71,8 @@ async def create_plan(self) -> BuildOrder: Step(None, BuildAddon(UnitTypeId.BARRACKSREACTOR, UnitTypeId.BARRACKS, 1)), Step(None, GridBuilding(UnitTypeId.STARPORT, 2)), Step( - UnitReady(UnitTypeId.STARPORT, 2), BuildAddon(UnitTypeId.STARPORTTECHLAB, UnitTypeId.STARPORT, 2), + UnitReady(UnitTypeId.STARPORT, 2), + BuildAddon(UnitTypeId.STARPORTTECHLAB, UnitTypeId.STARPORT, 2), ), Step(None, Tech(UpgradeId.SHIELDWALL)), Step(Minerals(600), GridBuilding(UnitTypeId.BARRACKS, 5)), @@ -89,7 +90,8 @@ async def create_plan(self) -> BuildOrder: None, ), Step( - UnitReady(UnitTypeId.STARPORT, 1), ActUnit(UnitTypeId.RAVEN, UnitTypeId.STARPORT, 2, priority=True), + UnitReady(UnitTypeId.STARPORT, 1), + ActUnit(UnitTypeId.RAVEN, UnitTypeId.STARPORT, 2, priority=True), ), ], ActUnit(UnitTypeId.BANSHEE, UnitTypeId.STARPORT, 20, priority=True), diff --git a/dummies/terran/battle_cruisers.py b/dummies/terran/battle_cruisers.py index 979f913f..a9703e03 100644 --- a/dummies/terran/battle_cruisers.py +++ b/dummies/terran/battle_cruisers.py @@ -110,13 +110,15 @@ async def create_plan(self) -> BuildOrder: 4, None, UnitExists(UnitTypeId.BATTLECRUISER, 1, include_killed=True, include_pending=True) ), Step( - UnitExists(UnitTypeId.BATTLECRUISER, 1, include_killed=True), GridBuilding(UnitTypeId.BARRACKS, 3), + UnitExists(UnitTypeId.BATTLECRUISER, 1, include_killed=True), + GridBuilding(UnitTypeId.BARRACKS, 3), ), Step(None, BuildAddon(UnitTypeId.BARRACKSTECHLAB, UnitTypeId.BARRACKS, 1)), Step(None, BuildAddon(UnitTypeId.BARRACKSREACTOR, UnitTypeId.BARRACKS, 1)), Step(None, GridBuilding(UnitTypeId.STARPORT, 2)), Step( - UnitReady(UnitTypeId.STARPORT, 2), BuildAddon(UnitTypeId.STARPORTTECHLAB, UnitTypeId.STARPORT, 2), + UnitReady(UnitTypeId.STARPORT, 2), + BuildAddon(UnitTypeId.STARPORTTECHLAB, UnitTypeId.STARPORT, 2), ), Step(None, Tech(UpgradeId.SHIELDWALL)), Step(Minerals(600), GridBuilding(UnitTypeId.BARRACKS, 5)), @@ -134,7 +136,8 @@ async def create_plan(self) -> BuildOrder: None, ), Step( - UnitReady(UnitTypeId.STARPORT, 1), ActUnit(UnitTypeId.RAVEN, UnitTypeId.STARPORT, 2, priority=True), + UnitReady(UnitTypeId.STARPORT, 1), + ActUnit(UnitTypeId.RAVEN, UnitTypeId.STARPORT, 2, priority=True), ), ], Step( diff --git a/dummies/terran/cyclones.py b/dummies/terran/cyclones.py index a7622d6a..6bdfff40 100644 --- a/dummies/terran/cyclones.py +++ b/dummies/terran/cyclones.py @@ -32,7 +32,11 @@ async def create_plan(self) -> BuildOrder: Step(None, Expand(3)), GridBuilding(UnitTypeId.FACTORY, 2), BuildAddon(UnitTypeId.FACTORYTECHLAB, UnitTypeId.FACTORY, 2), - Step(None, Tech(UpgradeId.CYCLONELOCKONDAMAGEUPGRADE), skip_until=UnitReady(UnitTypeId.FACTORYTECHLAB, 1),), + Step( + None, + Tech(UpgradeId.CYCLONELOCKONDAMAGEUPGRADE), + skip_until=UnitReady(UnitTypeId.FACTORYTECHLAB, 1), + ), BuildGas(5), Step(None, Tech(UpgradeId.HIGHCAPACITYBARRELS), skip_until=UnitReady(UnitTypeId.FACTORYTECHLAB, 2)), StepBuildGas(6, None, Gas(100)), @@ -93,7 +97,10 @@ async def create_plan(self) -> BuildOrder: ], [ Step(None, ActUnit(UnitTypeId.SCV, UnitTypeId.COMMANDCENTER, 40)), - Step(UnitExists(UnitTypeId.COMMANDCENTER, 3), ActUnit(UnitTypeId.SCV, UnitTypeId.COMMANDCENTER, 70),), + Step( + UnitExists(UnitTypeId.COMMANDCENTER, 3), + ActUnit(UnitTypeId.SCV, UnitTypeId.COMMANDCENTER, 70), + ), ], upgrades, ActUnit(UnitTypeId.MARINE, UnitTypeId.BARRACKS, 4), diff --git a/dummies/terran/rusty.py b/dummies/terran/rusty.py index b4936532..24a1e9ff 100644 --- a/dummies/terran/rusty.py +++ b/dummies/terran/rusty.py @@ -67,7 +67,10 @@ def __init__(self): buildings = [ Step(Supply(13), GridBuilding(UnitTypeId.SUPPLYDEPOT, 1)), StepBuildGas(1, Supply(16)), - Step(UnitExists(UnitTypeId.SUPPLYDEPOT), GridBuilding(UnitTypeId.BARRACKS, 1),), + Step( + UnitExists(UnitTypeId.SUPPLYDEPOT), + GridBuilding(UnitTypeId.BARRACKS, 1), + ), Step(UnitReady(UnitTypeId.BARRACKS, 0.25), GridBuilding(UnitTypeId.SUPPLYDEPOT, 2)), StepBuildGas(1, Supply(18)), Step(UnitExists(UnitTypeId.MARINE, 1), Expand(2)), diff --git a/dummies/terran/safe_tvt_raven.py b/dummies/terran/safe_tvt_raven.py index d4172198..d8eb9674 100644 --- a/dummies/terran/safe_tvt_raven.py +++ b/dummies/terran/safe_tvt_raven.py @@ -59,7 +59,8 @@ async def create_plan(self) -> BuildOrder: Step( UnitExists(UnitTypeId.FACTORY, include_pending=True), BuildOrder( - TerranUnit(UnitTypeId.REAPER, 3, only_once=True), TerranUnit(UnitTypeId.HELLION, 2, only_once=True), + TerranUnit(UnitTypeId.REAPER, 3, only_once=True), + TerranUnit(UnitTypeId.HELLION, 2, only_once=True), ), ), BuildOrder( @@ -168,7 +169,10 @@ async def create_plan(self) -> BuildOrder: units, # Build structures [ - Step(Supply(14), GridBuilding(UnitTypeId.SUPPLYDEPOT, 1),), + Step( + Supply(14), + GridBuilding(UnitTypeId.SUPPLYDEPOT, 1), + ), BuildGas(1), GridBuilding(UnitTypeId.BARRACKS, 1), StepBuildGas(2, requirement=Supply(17)), @@ -189,7 +193,10 @@ async def create_plan(self) -> BuildOrder: BuildGas(3), # At around 4:20, this command center should be placed in-base and flown out later # TODO Build 3rd CC inbase if possible - Step(Time(4 * 60 + 20), Expand(3),), + Step( + Time(4 * 60 + 20), + Expand(3), + ), AutoDepot(), Step( UnitExists(UnitTypeId.RAVEN, 2, include_pending=True, include_killed=True), @@ -211,11 +218,18 @@ async def create_plan(self) -> BuildOrder: GridBuilding(UnitTypeId.BARRACKS, 5), ), # Add 2nd factory when combatshield is nearly done - Step(TechReady(UpgradeId.SHIELDWALL, 0.6), GridBuilding(UnitTypeId.FACTORY, 2),), + Step( + TechReady(UpgradeId.SHIELDWALL, 0.6), + GridBuilding(UnitTypeId.FACTORY, 2), + ), # Add armory when +1 attack is nearly done Step( TechReady(UpgradeId.TERRANINFANTRYWEAPONSLEVEL1, 0.6), - GridBuilding(UnitTypeId.ARMORY, 1, priority=True,), + GridBuilding( + UnitTypeId.ARMORY, + 1, + priority=True, + ), ), # Research upgrades research, diff --git a/dummies/zerg/lings.py b/dummies/zerg/lings.py index 35730a5d..7a09dcdd 100644 --- a/dummies/zerg/lings.py +++ b/dummies/zerg/lings.py @@ -113,7 +113,11 @@ def __init__(self): UnitExists(UnitTypeId.QUEEN, 1), ), Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 20), None), - Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 12), None,), + Step( + UnitExists(UnitTypeId.SPAWNINGPOOL, 1), + ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 12), + None, + ), Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 30), None), # Endless zerglings Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA), None), diff --git a/dummies/zerg/lurkers.py b/dummies/zerg/lurkers.py index fc115265..bd16876c 100644 --- a/dummies/zerg/lurkers.py +++ b/dummies/zerg/lurkers.py @@ -56,27 +56,83 @@ class LurkerBuild(BuildOrder): def __init__(self): gas = SequentialList( [ - Step(None, BuildGas(2), skip=Gas(200), skip_until=Supply(25, supply_type=SupplyType.Workers),), - Step(None, BuildGas(3), skip=Gas(200), skip_until=Supply(40, supply_type=SupplyType.Workers),), - Step(None, BuildGas(4), skip=Gas(200), skip_until=Supply(50, supply_type=SupplyType.Workers),), Step( - Minerals(1000), BuildGas(6), skip=Gas(200), skip_until=Supply(50, supply_type=SupplyType.Workers), + None, + BuildGas(2), + skip=Gas(200), + skip_until=Supply(25, supply_type=SupplyType.Workers), ), Step( - Minerals(2000), BuildGas(8), skip=Gas(200), skip_until=Supply(50, supply_type=SupplyType.Workers), + None, + BuildGas(3), + skip=Gas(200), + skip_until=Supply(40, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(4), + skip=Gas(200), + skip_until=Supply(50, supply_type=SupplyType.Workers), + ), + Step( + Minerals(1000), + BuildGas(6), + skip=Gas(200), + skip_until=Supply(50, supply_type=SupplyType.Workers), + ), + Step( + Minerals(2000), + BuildGas(8), + skip=Gas(200), + skip_until=Supply(50, supply_type=SupplyType.Workers), ), ] ) heavy_gas = SequentialList( [ - Step(None, BuildGas(2), skip=Gas(300), skip_until=Supply(20, supply_type=SupplyType.Workers),), - Step(None, BuildGas(3), skip=Gas(300), skip_until=Supply(30, supply_type=SupplyType.Workers),), - Step(None, BuildGas(4), skip=Gas(300), skip_until=Supply(40, supply_type=SupplyType.Workers),), - Step(None, BuildGas(5), skip=Gas(300), skip_until=Supply(50, supply_type=SupplyType.Workers),), - Step(None, BuildGas(6), skip=Gas(300), skip_until=Supply(60, supply_type=SupplyType.Workers),), - Step(None, BuildGas(7), skip=Gas(300), skip_until=Supply(65, supply_type=SupplyType.Workers),), - Step(None, BuildGas(8), skip=Gas(300), skip_until=Supply(70, supply_type=SupplyType.Workers),), + Step( + None, + BuildGas(2), + skip=Gas(300), + skip_until=Supply(20, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(3), + skip=Gas(300), + skip_until=Supply(30, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(4), + skip=Gas(300), + skip_until=Supply(40, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(5), + skip=Gas(300), + skip_until=Supply(50, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(6), + skip=Gas(300), + skip_until=Supply(60, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(7), + skip=Gas(300), + skip_until=Supply(65, supply_type=SupplyType.Workers), + ), + Step( + None, + BuildGas(8), + skip=Gas(300), + skip_until=Supply(70, supply_type=SupplyType.Workers), + ), ] ) @@ -89,7 +145,10 @@ def __init__(self): SequentialList( # Opener Step(Supply(16), Expand(2)), - Step(Supply(18), PositionBuilding(UnitTypeId.SPAWNINGPOOL, DefensePosition.BehindMineralLineLeft, 0),), + Step( + Supply(18), + PositionBuilding(UnitTypeId.SPAWNINGPOOL, DefensePosition.BehindMineralLineLeft, 0), + ), StepBuildGas(1, Supply(20)), ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 4), ZergUnit(UnitTypeId.QUEEN, 2), diff --git a/dummies/zerg/macro_roach.py b/dummies/zerg/macro_roach.py index c2f01b1b..9e8fbe2d 100644 --- a/dummies/zerg/macro_roach.py +++ b/dummies/zerg/macro_roach.py @@ -36,7 +36,10 @@ async def create_plan(self) -> BuildOrder: ] buildings = [ - Step(UnitExists(UnitTypeId.HATCHERY, 2, include_pending=True), ActBuilding(UnitTypeId.SPAWNINGPOOL, 1),), + Step( + UnitExists(UnitTypeId.HATCHERY, 2, include_pending=True), + ActBuilding(UnitTypeId.SPAWNINGPOOL, 1), + ), Step(UnitExists(UnitTypeId.QUEEN, 2), ActBuilding(UnitTypeId.ROACHWARREN, 1)), ] @@ -67,7 +70,8 @@ async def create_plan(self) -> BuildOrder: Step(UnitExists(UnitTypeId.HATCHERY, 2), ActUnit(UnitTypeId.ROACH, UnitTypeId.LARVA, 4)), Step(None, ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 4)), Step( - UnitExists(UnitTypeId.HATCHERY, 3, include_pending=True), ActUnit(UnitTypeId.ROACH, UnitTypeId.LARVA), + UnitExists(UnitTypeId.HATCHERY, 3, include_pending=True), + ActUnit(UnitTypeId.ROACH, UnitTypeId.LARVA), ), ] diff --git a/dummies/zerg/mutalisk.py b/dummies/zerg/mutalisk.py index 76fefe71..5d9ab9c5 100644 --- a/dummies/zerg/mutalisk.py +++ b/dummies/zerg/mutalisk.py @@ -56,7 +56,9 @@ def __init__(self): high_tier = [ # Step(RequiredUnitReady(UnitTypeId.GREATERSPIRE), ZergUnit(UnitTypeId.DRONE, 70)), Step( - None, ZergUnit(UnitTypeId.CORRUPTOR, 3, priority=True), skip_until=UnitReady(UnitTypeId.GREATERSPIRE), + None, + ZergUnit(UnitTypeId.CORRUPTOR, 3, priority=True), + skip_until=UnitReady(UnitTypeId.GREATERSPIRE), ), Step(None, MorphBroodLord(5)), # Step(RequiredGas(200), ZergUnit(UnitTypeId.MUTALISK, 20, priority=True)) @@ -77,7 +79,12 @@ def __init__(self): Step(None, ZergUnit(UnitTypeId.MUTALISK, 4), skip_until=UnitReady(UnitTypeId.SPIRE, 1)), Step(None, ZergUnit(UnitTypeId.DRONE, 45), None), Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 16), None), - Step(None, ZergUnit(UnitTypeId.ROACH, 10), skip=UnitReady(UnitTypeId.SPIRE, 1), skip_until=Gas(25),), + Step( + None, + ZergUnit(UnitTypeId.ROACH, 10), + skip=UnitReady(UnitTypeId.SPIRE, 1), + skip_until=Gas(25), + ), Step(None, ZergUnit(UnitTypeId.DRONE, 65), None), Step( None, diff --git a/dummies/zerg/roach_hydra.py b/dummies/zerg/roach_hydra.py index 074b5c97..2fc39145 100644 --- a/dummies/zerg/roach_hydra.py +++ b/dummies/zerg/roach_hydra.py @@ -16,7 +16,11 @@ class RoachHydraBuild(BuildOrder): def __init__(self): gas_related = [ - Step(UnitExists(UnitTypeId.HATCHERY, 2), Tech(UpgradeId.ZERGLINGMOVEMENTSPEED), skip_until=Gas(100),), + Step( + UnitExists(UnitTypeId.HATCHERY, 2), + Tech(UpgradeId.ZERGLINGMOVEMENTSPEED), + skip_until=Gas(100), + ), Step(None, ActBuilding(UnitTypeId.ROACHWARREN, 1), skip_until=Gas(100)), StepBuildGas(2, Time(4 * 60), Gas(100)), StepBuildGas(3, UnitExists(UnitTypeId.HYDRALISKDEN, 1), Gas(50)), @@ -61,7 +65,11 @@ def __init__(self): Step(None, ActUnitOnce(UnitTypeId.ROACH, UnitTypeId.LARVA, 4), skip_until=Gas(25)), Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 100), skip_until=Minerals(750)), Step(None, ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 45), None), - Step(None, ActUnit(UnitTypeId.HYDRALISK, UnitTypeId.LARVA, 7), skip=UnitReady(UnitTypeId.HYDRALISKDEN, 1),), + Step( + None, + ActUnit(UnitTypeId.HYDRALISK, UnitTypeId.LARVA, 7), + skip=UnitReady(UnitTypeId.HYDRALISKDEN, 1), + ), Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 24), None), Step(None, ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 50), None), Step(None, ActUnit(UnitTypeId.ROACH, UnitTypeId.LARVA, 10), skip_until=Gas(25)), @@ -74,7 +82,7 @@ def __init__(self): class RoachHydra(KnowledgeBot): - """Zerg macro opener into longer game roach hydra """ + """Zerg macro opener into longer game roach hydra""" def __init__(self): super().__init__("Roach hydra") diff --git a/dummies/zerg/worker_rush.py b/dummies/zerg/worker_rush.py index 439576d7..4801e7db 100644 --- a/dummies/zerg/worker_rush.py +++ b/dummies/zerg/worker_rush.py @@ -142,7 +142,11 @@ def __init__(self): UnitExists(UnitTypeId.QUEEN, 1), ), Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 20), None), - Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 12), None,), + Step( + UnitExists(UnitTypeId.SPAWNINGPOOL, 1), + ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 12), + None, + ), Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 30), None), # Endless zerglings Step(UnitExists(UnitTypeId.SPAWNINGPOOL, 1), ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA), None), diff --git a/dummies/zerg/zerg_silver.py b/dummies/zerg/zerg_silver.py index f50438df..df31c983 100644 --- a/dummies/zerg/zerg_silver.py +++ b/dummies/zerg/zerg_silver.py @@ -26,7 +26,11 @@ def __init__(self): self.worker_rushed = False gas_related = [ - Step(UnitExists(UnitTypeId.HATCHERY, 2), Tech(UpgradeId.ZERGLINGMOVEMENTSPEED), skip_until=Gas(100),), + Step( + UnitExists(UnitTypeId.HATCHERY, 2), + Tech(UpgradeId.ZERGLINGMOVEMENTSPEED), + skip_until=Gas(100), + ), Step(None, ActBuilding(UnitTypeId.ROACHWARREN, 1), skip_until=Gas(100)), StepBuildGas(2, Time(4 * 60), Gas(100)), StepBuildGas(3, UnitExists(UnitTypeId.HYDRALISKDEN, 1), Gas(50)), @@ -86,7 +90,11 @@ def __init__(self): Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 16), None), Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 100), skip_until=Minerals(750)), Step(None, ZergUnit(UnitTypeId.DRONE, 45), None), - Step(None, ZergUnit(UnitTypeId.HYDRALISK, 7), skip=UnitReady(UnitTypeId.HYDRALISKDEN, 1),), + Step( + None, + ZergUnit(UnitTypeId.HYDRALISK, 7), + skip=UnitReady(UnitTypeId.HYDRALISKDEN, 1), + ), Step(None, ActUnitOnce(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 24), None), Step(None, ZergUnit(UnitTypeId.DRONE, 50), None), Step(None, ZergUnit(UnitTypeId.ROACH, 10), skip_until=Gas(25)), diff --git a/ladder.py b/ladder.py index 17c33c1d..f0e16606 100644 --- a/ladder.py +++ b/ladder.py @@ -165,4 +165,8 @@ def stand_alone_game(bot): file_name = f"IngameAI_{map_name}_{time}" path = f"{folder}/{file_name}.log" LoggingUtility.set_logger_file(log_level=get_config(False)["general"]["log_level"], path=path) - return sc2.main.run_game(sc2.maps.get(map_name), [bot, Computer(Race.Random, Difficulty.VeryHard)], realtime=False,) + return sc2.main.run_game( + sc2.maps.get(map_name), + [bot, Computer(Race.Random, Difficulty.VeryHard)], + realtime=False, + ) diff --git a/sc2pathlib/__init__.py b/sc2pathlib/__init__.py index 3a4ba556..389522a2 100644 --- a/sc2pathlib/__init__.py +++ b/sc2pathlib/__init__.py @@ -1,3 +1,3 @@ from .path_finder import PathFinder from .map import Sc2Map -from .mappings import MapType, MapsType \ No newline at end of file +from .mappings import MapType, MapsType diff --git a/sc2pathlib/choke.py b/sc2pathlib/choke.py index b59fbd3c..a0a02eaa 100644 --- a/sc2pathlib/choke.py +++ b/sc2pathlib/choke.py @@ -1,9 +1,10 @@ from typing import Tuple, List + class Choke: main_line: Tuple[Tuple[float, float], Tuple[float, float]] lines: List[Tuple[Tuple[int, int], Tuple[int, int]]] side1: List[Tuple[int, int]] side2: List[Tuple[int, int]] pixels: List[Tuple[int, int]] - min_length: float \ No newline at end of file + min_length: float diff --git a/sc2pathlib/map.py b/sc2pathlib/map.py index 2e0a7277..44027035 100644 --- a/sc2pathlib/map.py +++ b/sc2pathlib/map.py @@ -8,8 +8,9 @@ from sc2.unit import Unit from sc2.position import Point2 + class Sc2Map: - __slots__ = ['_overlord_spots', '_chokes', 'heuristic_accuracy', 'height_map', '_map'] + __slots__ = ["_overlord_spots", "_chokes", "heuristic_accuracy", "height_map", "_map"] def __init__( self, @@ -55,7 +56,6 @@ def chokes(self) -> List[Choke]: self._chokes = self._map.chokes return self._chokes - def reset(self): self._map.reset() @@ -94,7 +94,6 @@ def remove_connection(self, start: Tuple[float, float]) -> bool: """ return self._map.remove_connection(start) - def normalize_influence(self, value: int): self._map.normalize_influence(value) @@ -139,9 +138,7 @@ def add_pure_ground_influence( """ self._map.add_influence_fading(MapsType.PureGround, points, influence, full_range, fade_max_range) - def add_ground_influence( - self, points: List["Point2"], influence: float, full_range: float, fade_max_range: float - ): + def add_ground_influence(self, points: List["Point2"], influence: float, full_range: float, fade_max_range: float): self._map.add_influence_fading(MapsType.Ground, points, influence, full_range, fade_max_range) def add_air_influence(self, points: List["Point2"], influence: float, full_range: float, fade_max_range: float): @@ -166,11 +163,14 @@ def add_influence_without_zones(self, zones: List[int], value: float): self._map.add_influence_without_zones(zones, int(value)) def find_path( - self, map_type: MapType, start: Tuple[float, float], end: Tuple[float, float], + self, + map_type: MapType, + start: Tuple[float, float], + end: Tuple[float, float], large: bool = False, influence: bool = False, window: Optional[Tuple[Tuple[float, float], Tuple[float, float]]] = None, - distance_from_target: Optional[float] = None + distance_from_target: Optional[float] = None, ) -> Tuple[List[Tuple[int, int]], float]: """ Finds a path ignoring influence. @@ -185,7 +185,9 @@ def find_path( :return: Tuple of points and total distance. """ - return self._map.find_path(map_type, start, end, large, influence, self.heuristic_accuracy, window, distance_from_target) + return self._map.find_path( + map_type, start, end, large, influence, self.heuristic_accuracy, window, distance_from_target + ) def find_path_influence( self, map_type: MapType, start: Tuple[float, float], end: Tuple[float, float], large: bool = False @@ -221,7 +223,9 @@ def find_low_inside_walk( def clear_vision(self) -> None: self._map.clear_vision() - def add_vision_params(self, detector: bool, flying: bool, position: Tuple[float, float], sight_range: float) -> None: + def add_vision_params( + self, detector: bool, flying: bool, position: Tuple[float, float], sight_range: float + ) -> None: vision_unit = VisionUnit(detector, flying, position, sight_range) self.add_vision(vision_unit) @@ -250,7 +254,7 @@ def vision_status(self, position: Tuple[float, float]) -> VisionStatus: def plot_vision(self, image_name: str = "vision_map", resize: int = 4) -> None: """ Uses cv2 to draw current vision grid. - + requires opencv-python :param path: list of points to colorize @@ -279,8 +283,6 @@ def plot(self, image_name: str = "map", resize: int = 4): image = np.multiply(image, 42) self.plot_image(image, image_name, resize) - - def plot_ground_map(self, path: List[Tuple[int, int]], image_name: str = "ground_map", resize: int = 4): image = np.array(self._map.ground_pathing, dtype=np.uint8) @@ -332,10 +334,9 @@ def plot_zones(self, image_name: str = "map", resize: int = 4): def plot_image(self, image, image_name: str = "map", resize: int = 4): import cv2 + image = np.rot90(image, 1) resized = cv2.resize(image, dsize=None, fx=resize, fy=resize, interpolation=cv2.INTER_NEAREST) cv2.imshow(image_name, resized) cv2.waitKey(1) - - \ No newline at end of file diff --git a/sc2pathlib/mappings.py b/sc2pathlib/mappings.py index 6ebdb217..b978b8f3 100644 --- a/sc2pathlib/mappings.py +++ b/sc2pathlib/mappings.py @@ -1,18 +1,21 @@ from enum import IntEnum + class MapsType(IntEnum): PureGround = 0 Ground = 1 Air = 2 Both = 3 + class MapType(IntEnum): Ground = 0 Reaper = 1 Colossus = 2 Air = 3 + class VisionStatus(IntEnum): NotSeen = 0 Seen = 1 - Detected = 2 \ No newline at end of file + Detected = 2 diff --git a/sc2pathlib/path_finder.py b/sc2pathlib/path_finder.py index 642c46d2..afb4f523 100644 --- a/sc2pathlib/path_finder.py +++ b/sc2pathlib/path_finder.py @@ -68,11 +68,13 @@ def remove_block(self, center: Union[Tuple[float, float], List[Tuple[float, floa self._path_find.remove_block(center, size) def find_path( - self, start: Tuple[float, float], end: Tuple[float, float], + self, + start: Tuple[float, float], + end: Tuple[float, float], large: bool = False, influence: bool = False, window: Optional[Tuple[Tuple[float, float], Tuple[float, float]]] = None, - distance_from_target: Optional[float] = None + distance_from_target: Optional[float] = None, ) -> Tuple[List[Tuple[int, int]], float]: """ Finds a path ignoring influence. @@ -89,20 +91,28 @@ def find_path( start_int = (int(round(start[0])), int(round(start[1]))) end_int = (int(round(end[0])), int(round(end[1]))) if window is not None: - window = ((int(round(window[0][0])), int(round(window[0][1]))), - (int(round(window[1][0])), int(round(window[1][1])))) - return self._path_find.find_path(start_int, end_int, large, influence, self.heuristic_accuracy, window, distance_from_target) + window = ( + (int(round(window[0][0])), int(round(window[0][1]))), + (int(round(window[1][0])), int(round(window[1][1]))), + ) + return self._path_find.find_path( + start_int, end_int, large, influence, self.heuristic_accuracy, window, distance_from_target + ) def find_path_influence( self, start: Tuple[float, float], end: Tuple[float, float], large: bool = False ) -> Tuple[List[Tuple[int, int]], float]: return self.find_path(start, end, large, influence=True) - def safest_spot(self, destination_center: Tuple[float, float], walk_distance: float) -> Tuple[Tuple[int, int], float]: + def safest_spot( + self, destination_center: Tuple[float, float], walk_distance: float + ) -> Tuple[Tuple[int, int], float]: destination_int = (round(destination_center[0]), round(destination_center[1])) return self._path_find.lowest_influence_walk(destination_int, walk_distance) - def lowest_influence_in_grid(self, destination_center: Tuple[float, float], radius: int) -> Tuple[Tuple[int, int], float]: + def lowest_influence_in_grid( + self, destination_center: Tuple[float, float], radius: int + ) -> Tuple[Tuple[int, int], float]: destination_int = (round(destination_center[0]), round(destination_center[1])) return self._path_find.lowest_influence(destination_int, radius) diff --git a/sc2pathlib/sc2pathlib.cpython-311-x86_64-linux-gnu.so b/sc2pathlib/sc2pathlib.cpython-311-x86_64-linux-gnu.so index daf1811f..2f1ac63b 100644 Binary files a/sc2pathlib/sc2pathlib.cpython-311-x86_64-linux-gnu.so and b/sc2pathlib/sc2pathlib.cpython-311-x86_64-linux-gnu.so differ diff --git a/sharpy/combat/combat_units.py b/sharpy/combat/combat_units.py index 275c6685..ae65728c 100644 --- a/sharpy/combat/combat_units.py +++ b/sharpy/combat/combat_units.py @@ -39,7 +39,7 @@ def is_too_spread_out(self) -> bool: for unit in self.units: d = unit.distance_to(self.center) self._total_distance += d - self._area_by_circles += unit.radius ** 2 + self._area_by_circles += unit.radius**2 total_area_thing = (self._total_distance / len(self.units)) ** 2 # self.knowledge.print( # f"spread: {self._total_distance} d to {total_area_thing} r and _area_by_circles {self._area_by_circles }" diff --git a/sharpy/combat/default_micro_methods.py b/sharpy/combat/default_micro_methods.py index 68fec0f4..d7ecdad3 100644 --- a/sharpy/combat/default_micro_methods.py +++ b/sharpy/combat/default_micro_methods.py @@ -202,12 +202,12 @@ def valid_push_target(enemy): value_func: Callable[[Unit], float] if prio: - value_func = ( - lambda u: 1 if u.type_id in changelings else prio.get(u.type_id, -1) * (1 - u.shield_health_percentage) + value_func = lambda u: ( + 1 if u.type_id in changelings else prio.get(u.type_id, -1) * (1 - u.shield_health_percentage) ) else: - value_func = ( - lambda u: 1 + value_func = lambda u: ( + 1 if u.type_id in changelings else 2 * step.unit_values.power_by_type(u.type_id, 1 - u.shield_health_percentage) ) diff --git a/sharpy/combat/generic_micro.py b/sharpy/combat/generic_micro.py index 62b0b1d4..3cb3319a 100644 --- a/sharpy/combat/generic_micro.py +++ b/sharpy/combat/generic_micro.py @@ -36,10 +36,12 @@ def __init__(self): self.prio_dict: Optional[Dict[UnitTypeId, int]] = None self.model = CombatModel.StalkerToRoach self.cyclone_dodge = True - self.models_with_retreat = [CombatModel.StalkerToRoach, - CombatModel.StalkerToSpeedlings, - CombatModel.Melee, - CombatModel.StalkerToStalker] + self.models_with_retreat = [ + CombatModel.StalkerToRoach, + CombatModel.StalkerToSpeedlings, + CombatModel.Melee, + CombatModel.StalkerToStalker, + ] super().__init__() def should_retreat(self, unit: Unit) -> bool: @@ -133,8 +135,12 @@ def unit_solve_combat(self, unit: Unit, current_command: Action) -> Action: backstep = self.pather.find_weak_influence_ground(backstep, 4) return Action(backstep, False) - if (self.should_retreat(unit) and self.closest_group and not self.ready_to_shoot(unit) - and self.model in self.models_with_retreat): + if ( + self.should_retreat(unit) + and self.closest_group + and not self.ready_to_shoot(unit) + and self.model in self.models_with_retreat + ): backstep: Point2 = unit.position.towards(self.closest_group.center, -3) if unit.is_flying: backstep = self.pather.find_weak_influence_air(backstep, 4) diff --git a/sharpy/combat/group_combat_manager.py b/sharpy/combat/group_combat_manager.py index 5dc66ab5..1e90e3bc 100644 --- a/sharpy/combat/group_combat_manager.py +++ b/sharpy/combat/group_combat_manager.py @@ -41,7 +41,7 @@ def tags(self) -> List[int]: @property def regroup_threshold(self) -> float: - """ Percentage 0 - 1 on how many of the attacking units should actually be together when attacking""" + """Percentage 0 - 1 on how many of the attacking units should actually be together when attacking""" return self.rules.regroup_percentage @property diff --git a/sharpy/combat/micro_step.py b/sharpy/combat/micro_step.py index 5605419e..a55d4d37 100644 --- a/sharpy/combat/micro_step.py +++ b/sharpy/combat/micro_step.py @@ -115,7 +115,7 @@ def is_target(self, unit: Unit) -> bool: return not unit.is_memory and unit.can_be_attacked and not unit.is_hallucination and not unit.is_snapshot def min_range(self, unit: Unit) -> float: - """ If a unit can attack both ground and air return the minimum of the attack ranges. """ + """If a unit can attack both ground and air return the minimum of the attack ranges.""" ground_range = self.unit_values.ground_range(unit) air_range = self.unit_values.air_range(unit) if not self.unit_values.can_shoot_air(unit): @@ -125,7 +125,7 @@ def min_range(self, unit: Unit) -> float: return min(ground_range, air_range) def max_range(self, unit: Unit) -> float: - """ If a unit can attack both ground and air return the maximum of the attack ranges. """ + """If a unit can attack both ground and air return the maximum of the attack ranges.""" ground_range = self.unit_values.ground_range(unit) air_range = self.unit_values.air_range(unit) if not self.unit_values.can_shoot_air(unit): diff --git a/sharpy/combat/terran/micro_tanks.py b/sharpy/combat/terran/micro_tanks.py index 9030c85a..325a4c3d 100644 --- a/sharpy/combat/terran/micro_tanks.py +++ b/sharpy/combat/terran/micro_tanks.py @@ -72,8 +72,10 @@ def unit_solve_combat(self, unit: Unit, current_command: Action) -> Action: if unit.type_id == UnitTypeId.SIEGETANK and distance > 5 and distance < 13: # don't siege up on the main base ramp! - if (len(self.zone_manager.expansion_zones) > 0 - and unit.distance_to(self.zone_manager.expansion_zones[0].ramp.bottom_center) > 7): + if ( + len(self.zone_manager.expansion_zones) > 0 + and unit.distance_to(self.zone_manager.expansion_zones[0].ramp.bottom_center) > 7 + ): siege_mode = AbilityId.SIEGEMODE_SIEGEMODE if distance > unsiege_threshold and ( diff --git a/sharpy/combat/zerg/micro_swarmhosts.py b/sharpy/combat/zerg/micro_swarmhosts.py index f92bdd6d..147688c8 100644 --- a/sharpy/combat/zerg/micro_swarmhosts.py +++ b/sharpy/combat/zerg/micro_swarmhosts.py @@ -41,7 +41,12 @@ def unit_solve_combat(self, unit: Unit, current_command: Action) -> Action: if self.cd_manager.is_ready(unit.tag, AbilityId.EFFECT_SPAWNLOCUSTS): distance = self.pather.walk_distance(unit.position, center) if distance < HOST_RANGE: - return Action(center, False, AbilityId.EFFECT_SPAWNLOCUSTS, debug_comment="Spawning Locusts",) + return Action( + center, + False, + AbilityId.EFFECT_SPAWNLOCUSTS, + debug_comment="Spawning Locusts", + ) else: return Action(center, False) diff --git a/sharpy/general/rocks.py b/sharpy/general/rocks.py index ec3ee480..51bf417d 100644 --- a/sharpy/general/rocks.py +++ b/sharpy/general/rocks.py @@ -52,7 +52,6 @@ UnitTypeId.DESTRUCTIBLEROCK2X6VERTICAL, UnitTypeId.DESTRUCTIBLEROCKEX12X6VERTICAL, UnitTypeId.DESTRUCTIBLEROCKEX1VERTICALHUGE, - } breakable_rocks_6x6 = { diff --git a/sharpy/general/zone.py b/sharpy/general/zone.py index 10ea6b9f..7337d842 100644 --- a/sharpy/general/zone.py +++ b/sharpy/general/zone.py @@ -35,7 +35,7 @@ class Zone: ZONE_DANGER_RADIUS = 30 MAIN_ZONE_RAMP_MAX_RADIUS = 26 ZONE_RAMP_MAX_RADIUS = 15 - ZONE_RADIUS_SQUARED = ZONE_RADIUS ** 2 + ZONE_RADIUS_SQUARED = ZONE_RADIUS**2 VESPENE_GEYSER_DISTANCE = 10 def __init__(self, center_location, is_start_location, knowledge: "Knowledge", zone_manager: "ZoneManager"): @@ -315,7 +315,7 @@ def minerals_running_low(self) -> bool: @property def is_enemys(self) -> bool: - """ Is there an enemy town hall in this zone? """ + """Is there an enemy town hall in this zone?""" return self._is_enemys @property @@ -324,7 +324,7 @@ def is_neutral(self) -> bool: @property def is_ours(self) -> bool: - """ Is there a town hall of ours in this zone or have we walled it off?""" + """Is there a town hall of ours in this zone or have we walled it off?""" return self.our_townhall is not None or self.our_wall() @property diff --git a/sharpy/interfaces/enemy_units_manager.py b/sharpy/interfaces/enemy_units_manager.py index 268d7b01..edc73763 100644 --- a/sharpy/interfaces/enemy_units_manager.py +++ b/sharpy/interfaces/enemy_units_manager.py @@ -12,13 +12,13 @@ class IEnemyUnitsManager(ABC): """Keeps track of enemy units and structures. - Note that the class has many limitations, it does not account that - * banelings are created by sacrificing zerglings - * an archon is created by sacrificing two templars (dark templar or high templar). - * orbital commands are transformed from command centers. - * warp gates are transformed from gateways. - * - """ + Note that the class has many limitations, it does not account that + * banelings are created by sacrificing zerglings + * an archon is created by sacrificing two templars (dark templar or high templar). + * orbital commands are transformed from command centers. + * warp gates are transformed from gateways. + * + """ @property @abstractmethod diff --git a/sharpy/interfaces/unit_value.py b/sharpy/interfaces/unit_value.py index 130b84e0..8fa1ea33 100644 --- a/sharpy/interfaces/unit_value.py +++ b/sharpy/interfaces/unit_value.py @@ -73,7 +73,7 @@ def can_shoot_ground(self, unit: Unit) -> bool: @abstractmethod def can_assist_defense(self, unit: Unit) -> bool: - """ Returns true when unit is an utility unit that can help defend even if it cannot attack correct targets itself.""" + """Returns true when unit is an utility unit that can help defend even if it cannot attack correct targets itself.""" pass @abstractmethod @@ -111,5 +111,5 @@ def calc_total_power(self, units: Units) -> ExtendedPower: @abstractmethod def should_attack(self, unit: Unit): - """ Determines if the unit is something that should attack. """ + """Determines if the unit is something that should attack.""" pass diff --git a/sharpy/interfaces/zone_manager.py b/sharpy/interfaces/zone_manager.py index c05b6dc6..8d657df7 100644 --- a/sharpy/interfaces/zone_manager.py +++ b/sharpy/interfaces/zone_manager.py @@ -50,7 +50,7 @@ def enemy_start_location(self) -> Point2: @property @abstractmethod def enemy_main_zone(self) -> Zone: - """ Returns enemy main / start zone.""" + """Returns enemy main / start zone.""" pass @property diff --git a/sharpy/knowledges/knowledge.py b/sharpy/knowledges/knowledge.py index c434fb90..dbb1136e 100644 --- a/sharpy/knowledges/knowledge.py +++ b/sharpy/knowledges/knowledge.py @@ -72,7 +72,7 @@ def my_race(self): @property def enemy_race(self) -> Race: - """ Enemy random race gets updated when the bot meets one of the enemy units. """ + """Enemy random race gets updated when the bot meets one of the enemy units.""" return self.ai.enemy_race @property @@ -178,7 +178,7 @@ async def post_update(self): await manager.post_update() def step_took(self, ns_step: float): - """ Time taken in nanosecond for the current step to run. """ + """Time taken in nanosecond for the current step to run.""" if self.lag_handler: ms_step = ns_step / 1000 / 1000 self.lag_handler.step_took(ms_step) diff --git a/sharpy/knowledges/skeleton_bot.py b/sharpy/knowledges/skeleton_bot.py index 0d6619fd..b5135a81 100644 --- a/sharpy/knowledges/skeleton_bot.py +++ b/sharpy/knowledges/skeleton_bot.py @@ -147,7 +147,7 @@ def do( can_afford_check: bool = False, ignore_warning: bool = False, ) -> bool: - """ Adds a unit action to the 'self.actions' list which is then executed at the end of the frame. + """Adds a unit action to the 'self.actions' list which is then executed at the end of the frame. Training a unit:: diff --git a/sharpy/managers/core/building_solver.py b/sharpy/managers/core/building_solver.py index e7c8915d..29e6fffe 100644 --- a/sharpy/managers/core/building_solver.py +++ b/sharpy/managers/core/building_solver.py @@ -198,7 +198,7 @@ def buildings5x5(self) -> List[Point2]: async def start(self, knowledge: "Knowledge"): await super().start(knowledge) - if (len(self.zone_manager.expansion_zones) > 1): + if len(self.zone_manager.expansion_zones) > 1: self.grid = BuildGrid(self.knowledge) self.base_ramp = self.zone_manager.expansion_zones[0].ramp self.color_zone(self.zone_manager.expansion_zones[0], ZoneArea.OwnMainZone) diff --git a/sharpy/managers/core/enemy_units_manager.py b/sharpy/managers/core/enemy_units_manager.py index c8d62546..99fa2f18 100644 --- a/sharpy/managers/core/enemy_units_manager.py +++ b/sharpy/managers/core/enemy_units_manager.py @@ -16,13 +16,13 @@ class EnemyUnitsManager(ManagerBase, IEnemyUnitsManager): """Keeps track of enemy units and structures. - Note that the class has many limitations, it does not account that - * banelings are created by sacrificing zerglings - * an archon is created by sacrificing two templars (dark templar or high templar). - * orbital commands are transformed from command centers. - * warp gates are transformed from gateways. - * - """ + Note that the class has many limitations, it does not account that + * banelings are created by sacrificing zerglings + * an archon is created by sacrificing two templars (dark templar or high templar). + * orbital commands are transformed from command centers. + * warp gates are transformed from gateways. + * + """ unit_values: UnitValue @@ -71,7 +71,7 @@ def unit_count(self, unit_type: UnitTypeId) -> int: @property def enemy_total_power(self) -> ExtendedPower: """Returns the total power of all enemy units we currently know about. - Assumes they are all in full health. Ignores workers and overlords.""" + Assumes they are all in full health. Ignores workers and overlords.""" total_power = ExtendedPower(self.unit_values) for type_id in self._known_enemy_units_dict: if self.unit_values.is_worker(type_id): diff --git a/sharpy/managers/core/grids/grid.py b/sharpy/managers/core/grids/grid.py index 01c5648b..e53f4022 100644 --- a/sharpy/managers/core/grids/grid.py +++ b/sharpy/managers/core/grids/grid.py @@ -26,24 +26,23 @@ def get(self, x: int, y: int): return self._data[x][y] def __getitem__(self, pos: Point2): - """ Example usage: is_pathable = self._game_info.pathing_grid[Point2((20, 20))] == 0 """ + """Example usage: is_pathable = self._game_info.pathing_grid[Point2((20, 20))] == 0""" if not self.is_inside(pos): return self.get_default() return self.get(math.floor(pos[0]), math.floor(pos[1])) @abstractmethod - def get_default(self): - ... + def get_default(self): ... def is_inside(self, pos: Point2): return 0 <= pos[0] < self.width and 0 <= pos[1] < self.height def query_area(self, position: Point2, fillType: BlockerType, check) -> bool: - """ - Query that fails if any is true. - - True if all cells pass check func. + """ + Query that fails if any is true. + + True if all cells pass check func. """ area = self.get_area(position, fillType) return self.query_rect(area, check) diff --git a/sharpy/managers/core/unit_role_manager.py b/sharpy/managers/core/unit_role_manager.py index 6c1bfb1d..4d360e5f 100644 --- a/sharpy/managers/core/unit_role_manager.py +++ b/sharpy/managers/core/unit_role_manager.py @@ -124,7 +124,7 @@ def get_types_from(self, types: Set[UnitTypeId], *args: Union[int, UnitTask]) -> return units.tags_in(all_tags) def get_unit_by_tag_from_task(self, tag: int, task: Union[int, UnitTask]) -> Optional[Unit]: - """ Get unit by its tag from the specified role. """ + """Get unit by its tag from the specified role.""" if tag in self.roles[task].tags: return self.roles[task].units.by_tag(tag) return None @@ -157,7 +157,7 @@ def _defenders_from( power: ExtendedPower, units: Units, ): - """ Get defenders from a task. """ + """Get defenders from a task.""" if current_power.is_enough_for(power): return @@ -209,14 +209,14 @@ def free_units(self) -> Units: @property def idle_workers(self) -> Units: - """ Free workers, ie. gathering minerals or gas, or idling, and not dedicated to defending or scouting.""" + """Free workers, ie. gathering minerals or gas, or idling, and not dedicated to defending or scouting.""" units: Units = self.roles[UnitTask.Idle].units # Mules should not count for workers return units.of_type([UnitTypeId.DRONE, UnitTypeId.PROBE, UnitTypeId.SCV]) @property def free_workers(self) -> Units: - """ Free workers, ie. gathering minerals or gas, or idling, and not dedicated to defending or scouting.""" + """Free workers, ie. gathering minerals or gas, or idling, and not dedicated to defending or scouting.""" units: Units = Units(self.roles[UnitTask.Idle].units, self.ai) units.extend(self.roles[UnitTask.Gathering].units) # Mules should not count for workers diff --git a/sharpy/managers/core/version_manager.py b/sharpy/managers/core/version_manager.py index 1657a65b..3a5937c7 100644 --- a/sharpy/managers/core/version_manager.py +++ b/sharpy/managers/core/version_manager.py @@ -146,7 +146,8 @@ def configure_enums(self): ) if GameVersion.V_4_10_0 < self.base_version < GameVersion.V_4_12_0: self._set_enum_mapping( - AbilityId, {AbilityId.AMORPHOUSARMORCLOUD_AMORPHOUSARMORCLOUD: 3801}, + AbilityId, + {AbilityId.AMORPHOUSARMORCLOUD_AMORPHOUSARMORCLOUD: 3801}, ) def set_version_to_410_with_new_balance(self): @@ -178,7 +179,8 @@ def set_version_to_410_with_new_balance(self): }, ) self._set_enum_mapping( - BuffId, {BuffId.INHIBITORZONETEMPORALFIELD: 292, BuffId.RESONATINGGLAIVESPHASESHIFT: 293}, + BuffId, + {BuffId.INHIBITORZONETEMPORALFIELD: 292, BuffId.RESONATINGGLAIVESPHASESHIFT: 293}, ) # UpgradeIds not changed diff --git a/sharpy/managers/core/zone_manager.py b/sharpy/managers/core/zone_manager.py index 38597048..3336bbf5 100644 --- a/sharpy/managers/core/zone_manager.py +++ b/sharpy/managers/core/zone_manager.py @@ -287,7 +287,7 @@ def adjust_zones(self): self._cached_enemy_base_ramp = None def init_zone_pathing(self): - """ Init zone pathing. This needs to be run after all managers have properly started. """ + """Init zone pathing. This needs to be run after all managers have properly started.""" pf: sc2pathlib.PathFinder = self.knowledge.pathing_manager.path_finder_terrain zone_count = len(self._expansion_zones) for i in range(0, zone_count): @@ -615,7 +615,7 @@ def enemy_start_location(self) -> Point2: @property def enemy_main_zone(self) -> Zone: - """ Returns enemy main / start zone.""" + """Returns enemy main / start zone.""" # todo: maybe at some point this could return enemy's actual main base, if it has lost the start location. # todo: detection could be base on eg. number of tech buildings return self._expansion_zones[len(self._expansion_zones) - 1] diff --git a/sharpy/managers/extensions/build_detector.py b/sharpy/managers/extensions/build_detector.py index 6116d8be..bde4b495 100644 --- a/sharpy/managers/extensions/build_detector.py +++ b/sharpy/managers/extensions/build_detector.py @@ -121,7 +121,7 @@ def _update_timings(self): list.append(start_time) def started(self, type_id: UnitTypeId, index: int = 0) -> float: - """ Returns an absurdly large number when the building isn't started yet""" + """Returns an absurdly large number when the building isn't started yet""" list = self.timings.get(type_id, None) if not list: return sys.float_info.max diff --git a/sharpy/managers/extensions/enemy_army_predicter.py b/sharpy/managers/extensions/enemy_army_predicter.py index 0e35e1b7..63c60f13 100644 --- a/sharpy/managers/extensions/enemy_army_predicter.py +++ b/sharpy/managers/extensions/enemy_army_predicter.py @@ -80,12 +80,12 @@ async def start(self, knowledge: "Knowledge"): @property def own_value(self): - """ Our exact army value that we know of """ + """Our exact army value that we know of""" return self.own_army_value_minerals + self.own_army_value_gas @property def enemy_value(self): - """ Best estimation on how big value enemy army has """ + """Best estimation on how big value enemy army has""" return self.predicted_enemy_army_minerals + self.predicted_enemy_army_gas async def update(self): diff --git a/sharpy/plans/acts/act_base.py b/sharpy/plans/acts/act_base.py index 6a5e1e02..cadbb697 100644 --- a/sharpy/plans/acts/act_base.py +++ b/sharpy/plans/acts/act_base.py @@ -84,7 +84,7 @@ async def execute(self) -> bool: pass def pending_build(self, unit_type: UnitTypeId) -> float: - """ Only counts buildings that are commanded to be built, not ready builds are not included""" + """Only counts buildings that are commanded to be built, not ready builds are not included""" return self.get_count(unit_type) - self.get_count(unit_type, include_pending=False) def pending_building_positions(self, unit_type: UnitTypeId) -> List[Point2]: diff --git a/sharpy/plans/acts/expand.py b/sharpy/plans/acts/expand.py index bbdc449f..829b9234 100644 --- a/sharpy/plans/acts/expand.py +++ b/sharpy/plans/acts/expand.py @@ -202,7 +202,7 @@ async def debug_actions(self): self.client.debug_text_world(moving_status, worker.position3d) def expanding_in(self, zone: "Zone") -> bool: - """ Are we already expanding to this location? """ + """Are we already expanding to this location?""" creation_ability: AbilityId = self.ai._game_data.units[self.townhall_type.value].creation_ability for worker in self.ai.workers: for order in worker.orders: diff --git a/sharpy/plans/acts/grid_building.py b/sharpy/plans/acts/grid_building.py index 9b1e4cae..92f80047 100644 --- a/sharpy/plans/acts/grid_building.py +++ b/sharpy/plans/acts/grid_building.py @@ -356,7 +356,7 @@ def is_on_creep(self, creep: PixelMap, point: Point2) -> bool: return True def prequisite_progress(self) -> float: - """ Return progress in realtime seconds """ + """Return progress in realtime seconds""" # Protoss: if self.unit_type == UnitTypeId.GATEWAY or self.unit_type == UnitTypeId.FORGE: return self.building_progress(UnitTypeId.PYLON) diff --git a/sharpy/plans/acts/workers.py b/sharpy/plans/acts/workers.py index 20cc0e97..14a723bf 100644 --- a/sharpy/plans/acts/workers.py +++ b/sharpy/plans/acts/workers.py @@ -11,7 +11,6 @@ class Workers(ActBase): - """ Builds workers in an optimal way for Protoss and Terran. Does not function for Zerg! diff --git a/sharpy/plans/require/tech_ready.py b/sharpy/plans/require/tech_ready.py index 5c6b9d95..6463280d 100644 --- a/sharpy/plans/require/tech_ready.py +++ b/sharpy/plans/require/tech_ready.py @@ -8,7 +8,7 @@ class TechReady(RequireBase): # Check at tech research progress """Require that a specific upgrade/technology already exists or is at - least at the required percentage.""" + least at the required percentage.""" def __init__(self, upgrade: UpgradeId, percentage: float = 1): assert upgrade is not None and isinstance(upgrade, UpgradeId) diff --git a/sharpy/plans/tactics/protoss/double_adept_scout.py b/sharpy/plans/tactics/protoss/double_adept_scout.py index ff738a94..92d175d0 100644 --- a/sharpy/plans/tactics/protoss/double_adept_scout.py +++ b/sharpy/plans/tactics/protoss/double_adept_scout.py @@ -125,7 +125,7 @@ async def micro_adepts(self, adepts: Units): self.combat.execute(local_target, MoveType.Harass, rules=self.micro) async def select_targets(self, center: Point2) -> (Point2, Point2): - """ Returns none if no valid target was found. """ + """Returns none if no valid target was found.""" closest_viable_zone: Zone = None second_viable_zone: Zone = None current_zone_index: Optional[int] = None diff --git a/sharpy/plans/tactics/speed_mining.py b/sharpy/plans/tactics/speed_mining.py index cbddc035..7b28522e 100644 --- a/sharpy/plans/tactics/speed_mining.py +++ b/sharpy/plans/tactics/speed_mining.py @@ -13,7 +13,7 @@ class SpeedMining(ActBase): - """ Make worker mine faster perhaps? """ + """Make worker mine faster perhaps?""" def __init__(self, enable_on_return=True, enable_on_mine=True) -> None: super().__init__() diff --git a/sharpy/plans/tactics/terran/addon_swap.py b/sharpy/plans/tactics/terran/addon_swap.py index 3d1645cd..8b7823f6 100644 --- a/sharpy/plans/tactics/terran/addon_swap.py +++ b/sharpy/plans/tactics/terran/addon_swap.py @@ -164,7 +164,7 @@ async def update_units(self): self.structures_at_positions = {unit.position: unit for unit in all_production} async def check_if_plan_is_completed(self): - """ Checks if all structures are satisfied with their addon count. """ + """Checks if all structures are satisfied with their addon count.""" self.completed = True for production_type in PRODUCTION_TYPES: @@ -177,7 +177,7 @@ async def check_if_plan_is_completed(self): return async def plan_addon_swaps(self): - """ Main function which first tries to move structures away from addons, then attaches them. """ + """Main function which first tries to move structures away from addons, then attaches them.""" await self.mark_unused_addon_locations() await self.mark_structures_for_possible_dettach() await self.plan_attach_to_addons() @@ -198,7 +198,7 @@ async def mark_unused_addon_locations(self): self.building_solver.free_addon_locations.add(pos) async def mark_structures_for_possible_dettach(self): - """ Marks all structures, that should no longer use their addons, as dettachable. """ + """Marks all structures, that should no longer use their addons, as dettachable.""" for production_type in PRODUCTION_TYPES: for addon_type in ADDON_TYPES: production_with_addon: Units = self.production_with_addon[production_type][addon_type] @@ -276,12 +276,12 @@ def position_terran(self, unit: Unit) -> Optional[Point2]: return current_location async def lift_away_from_addon(self, unit: Unit): - """ Plan to move structure away from addon. Find a free location to land to. """ + """Plan to move structure away from addon. Find a free location to land to.""" land_position = await self.find_land_location_with_addon(unit, addon_type=None) await self.lift_to_target_location(unit, land_position) async def lift_to_target_location(self, unit: Unit, location: Point2): - """ Plan to move structure to target location. Reserve the location to not be used by any other structure or a GridBuilding() command. """ + """Plan to move structure to target location. Reserve the location to not be used by any other structure or a GridBuilding() command.""" self.building_solver.structure_target_move_location[unit.tag] = location async def find_land_location_with_addon(self, unit: Unit, addon_type: UnitTypeId = None) -> Optional[Point2]: @@ -321,7 +321,7 @@ async def find_land_location_with_addon(self, unit: Unit, addon_type: UnitTypeId return unit.position.closest(locations_with_structures) def has_addon(self, unit: Unit, addon_type: UnitTypeId): - """ Checks if a unit (specifically: its tag) has the specific addon type or is planned to have the specific addon type. """ + """Checks if a unit (specifically: its tag) has the specific addon type or is planned to have the specific addon type.""" assert addon_type in {UnitTypeId.TECHLAB, UnitTypeId.REACTOR} if unit.tag in self.building_solver.structure_target_move_location: # If structure is ordered to move to a location which has a techlab, return true diff --git a/sharpy/plans/tactics/warn_build_macro.py b/sharpy/plans/tactics/warn_build_macro.py index 10d564b5..f40abcc2 100644 --- a/sharpy/plans/tactics/warn_build_macro.py +++ b/sharpy/plans/tactics/warn_build_macro.py @@ -59,5 +59,5 @@ async def execute(self) -> bool: return True def time_formatted(self, t: float) -> str: - """ Returns time as string in min:sec format """ + """Returns time as string in min:sec format""" return f"{int(t // 60):02}:{int(t % 60):02}" diff --git a/sharpy/plans/tactics/weak/weak_defense.py b/sharpy/plans/tactics/weak/weak_defense.py index b4761dd2..adc4adab 100644 --- a/sharpy/plans/tactics/weak/weak_defense.py +++ b/sharpy/plans/tactics/weak/weak_defense.py @@ -19,7 +19,7 @@ class WeakDefense(ActBase): def __init__(self): super().__init__() - self.worker_return_distance2 = 10 ** 10 + self.worker_return_distance2 = 10**10 self.defender_tags: Dict[int, List[int]] = dict() self.defender_secondary_tags: Dict[int, List[int]] = dict() diff --git a/sharpy/plans/tactics/zerg/counter_terran_tie.py b/sharpy/plans/tactics/zerg/counter_terran_tie.py index 3ab4ca83..2616fe76 100644 --- a/sharpy/plans/tactics/zerg/counter_terran_tie.py +++ b/sharpy/plans/tactics/zerg/counter_terran_tie.py @@ -31,7 +31,9 @@ def __init__(self, orders: List[Union[ActBase, List[ActBase]]]): skip_until=Supply(199), ), Step( - None, DefensiveBuilding(UnitTypeId.SPINECRAWLER, DefensePosition.Entrance), skip_until=Supply(199), + None, + DefensiveBuilding(UnitTypeId.SPINECRAWLER, DefensePosition.Entrance), + skip_until=Supply(199), ), ZergUnit(UnitTypeId.MUTALISK, 10), ] diff --git a/sharpy/plans/tactics/zerg/spread_creep2.py b/sharpy/plans/tactics/zerg/spread_creep2.py index b9219acf..81a12d20 100644 --- a/sharpy/plans/tactics/zerg/spread_creep2.py +++ b/sharpy/plans/tactics/zerg/spread_creep2.py @@ -68,7 +68,7 @@ def create_target_tumor_locations(self): ] def fill_reserved_expansion_positions(self): - """ Fill all locations where no creep tumor should be planted at. """ + """Fill all locations where no creep tumor should be planted at.""" for expansion in self.ai.expansion_locations_list: xx, yy = [int(i) for i in expansion] for x in range(-2, 3): @@ -121,7 +121,7 @@ async def update_available_tumor_locations(self): self.available_tumor_locations.append(point) async def spread_creep_tumors(self): - """ Orders tumors to plant new tumors. """ + """Orders tumors to plant new tumors.""" tumors = self.cache.own(UnitTypeId.CREEPTUMORBURROWED) for tumor in tumors: # type: Unit @@ -132,7 +132,7 @@ async def spread_creep_tumors(self): tumor(AbilityId.BUILD_CREEPTUMOR_TUMOR, position) async def spawn_creep_tumors(self): - """ Order queens to plant tumors. """ + """Order queens to plant tumors.""" all_queens = self.cache.own(UnitTypeId.QUEEN) # todo: include burrowed queens? if all_queens.empty: return @@ -158,7 +158,7 @@ async def spawn_creep_tumors(self): queen.move(self.ai.townhalls.closest_to(queen).position) def get_next_plant_position(self, queen: Unit) -> Optional[Point2]: - """ Tries to find a suitable position for queens to plant tumors at. """ + """Tries to find a suitable position for queens to plant tumors at.""" # Map is covered in creep, no need to place more tumors if not self.available_tumor_locations: @@ -197,7 +197,7 @@ def get_next_plant_position(self, queen: Unit) -> Optional[Point2]: return queen_pos def get_next_creep_tumor_position(self, tumor: Unit) -> Optional[Point2]: - """ Tries to find a suitable position for tumors to move to next. """ + """Tries to find a suitable position for tumors to move to next.""" tumor_pos: Point2 = tumor.position # TODO Find the closest by ground path instead of air distance target_pos = tumor_pos.closest(self.available_tumor_locations) @@ -215,7 +215,7 @@ def get_next_creep_tumor_position(self, tumor: Unit) -> Optional[Point2]: return self.get_next_creep_tumor_position2(tumor) def get_next_creep_tumor_position2(self, tumor: Unit) -> Optional[Point2]: - """ The old version of the find creep tumor locations in case the one above find a suitable location. """ + """The old version of the find creep tumor locations in case the one above find a suitable location.""" towards = self.zone_manager.enemy_main_zone.center_location # iterate a few times so we find a suitable position @@ -233,11 +233,11 @@ def get_next_creep_tumor_position2(self, tumor: Unit) -> Optional[Point2]: return None def is_placeable(self, position: Point2) -> bool: - """ Filters out locations that - - Filter locations that are already target of tumors - - Have no creep ('illegal' for tumors and queens to plant at this locations) - - Would block expansion locations - - Are used by other structures? Or what does building_solver actually do? + """Filters out locations that + - Filter locations that are already target of tumors + - Have no creep ('illegal' for tumors and queens to plant at this locations) + - Would block expansion locations + - Are used by other structures? Or what does building_solver actually do? """ return ( position not in self.tumor_used_locations diff --git a/sharpy/plans/tactics/zone_defense.py b/sharpy/plans/tactics/zone_defense.py index 818e0ee9..c004c4c8 100644 --- a/sharpy/plans/tactics/zone_defense.py +++ b/sharpy/plans/tactics/zone_defense.py @@ -19,7 +19,7 @@ class PlanZoneDefense(ActBase): def __init__(self): super().__init__() - self.worker_return_distance2 = 10 ** 10 + self.worker_return_distance2 = 10**10 self.defender_tags: Dict[int, List[int]] = dict() self.defender_secondary_tags: Dict[int, List[int]] = dict() diff --git a/sharpy/sc2math.py b/sharpy/sc2math.py index f20c54d1..3b1cab05 100644 --- a/sharpy/sc2math.py +++ b/sharpy/sc2math.py @@ -52,8 +52,8 @@ def _get_intersections(x0: float, y0: float, r0: float, x1: float, y1: float, r1 if d == 0 and r0 == r1: return [] else: - a = (r0 ** 2 - r1 ** 2 + d ** 2) / (2 * d) - h = math.sqrt(r0 ** 2 - a ** 2) + a = (r0**2 - r1**2 + d**2) / (2 * d) + h = math.sqrt(r0**2 - a**2) x2 = x0 + a * (x1 - x0) / d y2 = y0 + a * (y1 - y0) / d x3 = x2 + h * (y1 - y0) / d @@ -90,10 +90,10 @@ def line_angle(from_point: Point2, to_point: Point2): def point_angle(point: Point2) -> float: """ - (x,y) = (1,0) => -pi /2 - (x,y) = (0,-1) => 0 - (x,y) = (0,1) => pi - (x,y) = (-1,0) => pi / 2 + (x,y) = (1,0) => -pi /2 + (x,y) = (0,-1) => 0 + (x,y) = (0,1) => pi + (x,y) = (-1,0) => pi / 2 """ if point.y == 0: if point.x > 0: @@ -137,7 +137,7 @@ def angle_distance(angle1: float, angle2: float): def point_normalize(point: Point2) -> Point2: if point.x == 0 and point.y == 0: return point - length = math.sqrt(point.x ** 2 + point.y ** 2) + length = math.sqrt(point.x**2 + point.y**2) return Point2((point.x / length, point.y / length)) @@ -176,7 +176,7 @@ def compute_euclidean_distance_matrix(locations): def unit_geometric_median(units: Units, accuracy=0.5) -> Point2: - """ Calculates geometric median based on units, returns (0,0) if no units exist """ + """Calculates geometric median based on units, returns (0,0) if no units exist""" if len(units) == 0: return Point2((0, 0))