Esempio n. 1
0
 async def create_plan(self) -> BuildOrder:
     flying_buildings = lambda k: self._bot.enemy_structures.flying.exists and self._bot.supply_used > 30
     in_case_of_air = [
         Step(flying_buildings, StepBuildGas(2)),
         ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 20),
         MorphLair(),
         ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 30),
         StepBuildGas(4),
         ActBuilding(UnitTypeId.SPIRE),
         ZergUnit(UnitTypeId.MUTALISK, 10, priority=True)
     ]
     return BuildOrder([
         SequentialList([
             ActBuilding(UnitTypeId.SPAWNINGPOOL, 1),
             ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 14),
             StepBuildGas(1),
             ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 14),
             ActUnit(UnitTypeId.OVERLORD, UnitTypeId.LARVA, 2),
             ActBuilding(UnitTypeId.ROACHWARREN, 1),
             ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 14),
             ActUnit(UnitTypeId.QUEEN, UnitTypeId.HATCHERY, 1),
             ActUnit(UnitTypeId.ROACH, UnitTypeId.LARVA, 100),
         ]), in_case_of_air,
         SequentialList([
             DistributeWorkers(),
             Step(None, SpeedMining(), lambda ai: ai.client.game_step > 5),
             PlanZoneDefense(),
             AutoOverLord(),
             InjectLarva(),
             PlanZoneGather(),
             Step(UnitExists(UnitTypeId.ROACH, 7), PlanZoneAttackAllIn(1)),
             PlanFinishEnemy(),
         ])
     ])
Esempio n. 2
0
    def __init__(self, orders: List[Union[ActBase, List[ActBase]]]):
        """
        Build order package that replaces normal build order for Zerg with one that builds mutalisks to destroy terran
        flying buildings.
        Add any PlanDistributeWorkers acts with orders
        """
        cover_list = SequentialList([
            PlanDistributeWorkers(),
            AutoOverLord(),
            Step(None, ZergUnit(UnitTypeId.DRONE, 20), skip=Supply(198)),
            StepBuildGas(4, None),
            MorphLair(),
            ActBuilding(UnitTypeId.SPIRE, 1),
            Step(
                None,
                DefensiveBuilding(UnitTypeId.SPORECRAWLER,
                                  DefensePosition.BehindMineralLineCenter),
                skip_until=Supply(199),
            ),
            Step(
                None,
                DefensiveBuilding(UnitTypeId.SPINECRAWLER,
                                  DefensePosition.Entrance),
                skip_until=Supply(199),
            ),
            ZergUnit(UnitTypeId.MUTALISK, 10),
        ])

        new_build_order = [
            Step(None, cover_list, skip_until=self.should_build_mutalisks),
            Step(None, BuildOrder(orders), skip=self.should_build_mutalisks),
        ]
        super().__init__(new_build_order)
Esempio n. 3
0
 async def create_plan(self) -> BuildOrder:
     flying_buildings = lambda k: self._bot.enemy_structures.flying.exists and self._bot.supply_used > 30
     in_case_of_air = [
         Step(flying_buildings, StepBuildGas(2)),
         ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 20),
         MorphLair(),
         ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 30),
         StepBuildGas(4),
         ActBuilding(UnitTypeId.SPIRE),
         ZergUnit(UnitTypeId.MUTALISK, 10, priority=True)
     ]
     limit_gas = Any(
         [Gas(100),
          TechReady(UpgradeId.ZERGLINGMOVEMENTSPEED, 0.001)])
     return BuildOrder([
         SequentialList([
             ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 14),
             Expand(2),
             StepBuildGas(1),
             ActBuilding(UnitTypeId.SPAWNINGPOOL, 1),
             ActUnit(UnitTypeId.OVERLORD, UnitTypeId.LARVA, 2),
             Step(None,
                  Tech(UpgradeId.ZERGLINGMOVEMENTSPEED,
                       UnitTypeId.SPAWNINGPOOL),
                  skip_until=Gas(100)),
             ActUnit(UnitTypeId.QUEEN, UnitTypeId.HATCHERY, 1),
             ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 30),
             ActBuilding(UnitTypeId.BANELINGNEST, 1),
             BuildOrder([
                 Step(None,
                      ActUnit(UnitTypeId.ZERGLING, UnitTypeId.LARVA, 200),
                      skip=RequireCustom(lambda k: self._bot.vespene > 25 or
                                         flying_buildings)),
                 Step(None,
                      ActUnit(UnitTypeId.BANELING, UnitTypeId.ZERGLING,
                              200),
                      skip=RequireCustom(flying_buildings)),
             ])
         ]),
         SequentialList([
             Step(None, DistributeWorkers(), skip=limit_gas),
             Step(limit_gas,
                  DistributeWorkers(1, 1),
                  skip=RequireCustom(flying_buildings)),
             Step(RequireCustom(flying_buildings), DistributeWorkers()),
         ]), in_case_of_air,
         SequentialList([
             Step(None, SpeedMining(), lambda ai: ai.client.game_step > 5),
             PlanZoneDefense(),
             AutoOverLord(),
             InjectLarva(),
             PlanZoneGather(),
             Step(TechReady(UpgradeId.ZERGLINGMOVEMENTSPEED),
                  PlanZoneAttackAllIn(10)),
             PlanFinishEnemy(),
         ])
     ])
Esempio n. 4
0
    def __init__(self):
        """Set everything up."""
        self.enemy_rushes = {
            EnemyBuild.GeneralRush,
            EnemyBuild.Pool12,
            EnemyBuild.RoachRush,
            EnemyBuild.LingRush,
            EnemyBuild.CannonRush,
            EnemyBuild.EarlyMarines,
        }
        self.distribute = PlanDistributeWorkers()

        # basic build (17, 18, 17)
        base_build = SequentialList([
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=13)),
            Step(None, ZergUnit(UnitTypeId.OVERLORD, to_count=2)),
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=17)),
            Step(
                None,
                ActExpand(to_count=2,
                          priority=True,
                          consider_worker_production=False)),
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=18)),
            Step(RequiredMinerals(120), StepBuildGas(to_count=1)),
            Step(None, ActBuilding(UnitTypeId.SPAWNINGPOOL)),
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=20)),
            Step(UnitExists(UnitTypeId.SPAWNINGPOOL),
                 ZergUnit(UnitTypeId.ZERGLING, to_count=6)),
            Step(UnitExists(UnitTypeId.SPAWNINGPOOL),
                 ZergUnit(UnitTypeId.QUEEN, to_count=2)),
            Step(
                RequiredAll(
                    [UnitExists(UnitTypeId.SPAWNINGPOOL),
                     RequiredGas(100)]),
                ActTech(UpgradeId.ZERGLINGMOVEMENTSPEED),
            ),
            Step(UnitExists(UnitTypeId.SPAWNINGPOOL),
                 ZergUnit(UnitTypeId.ZERGLING, to_count=100)),
        ])

        build_together = BuildOrder([
            Step(None,
                 base_build,
                 skip=lambda k: k.ai.scout_manager.enemy_build in self.
                 enemy_rushes),
            Step(None,
                 RoachRushResponse(),
                 skip=lambda k: k.ai.scout_manager.enemy_build != EnemyBuild.
                 RoachRush),
        ])

        super().__init__(build_together, self.distribute, AutoOverLord(),
                         InjectLarva(), SpreadCreep())
Esempio n. 5
0
 def __init__(self):
     """Create the build order."""
     opener = SequentialList(
         Step(
             RequiredUnitReady(UnitTypeId.SPAWNINGPOOL),
             NatSpines(4),
             skip=RequiredUnitReady(UnitTypeId.SPINECRAWLER, count=4),
             skip_until=lambda k: k.build_detector.rush_detected,
         ), Step(None, ZergUnit(UnitTypeId.DRONE, to_count=13)),
         Step(None, ZergUnit(UnitTypeId.OVERLORD, to_count=2)),
         Step(None, ZergUnit(UnitTypeId.DRONE, to_count=17)),
         Step(None,
              ActExpand(2, priority=True,
                        consider_worker_production=False)),
         Step(
             UnitExists(UnitTypeId.HATCHERY,
                        count=2,
                        include_pending=True,
                        include_not_ready=True),
             ZergUnit(UnitTypeId.DRONE, to_count=18),
         ), Step(None, ActBuilding(UnitTypeId.SPAWNINGPOOL)),
         Step(None, ZergUnit(UnitTypeId.DRONE, to_count=20)),
         StepBuildGas(1),
         Step(RequiredUnitReady(UnitTypeId.SPAWNINGPOOL),
              ZergUnit(UnitTypeId.QUEEN, 2)),
         Step(RequiredUnitReady(UnitTypeId.SPAWNINGPOOL),
              ZergUnit(UnitTypeId.ZERGLING, 6)),
         Step(None, ZergUnit(UnitTypeId.OVERLORD, to_count=3)),
         BuildOrder([
             Step(RequiredGas(100), MorphLair()),
             Step(
                 None,
                 ZergUnit(UnitTypeId.DRONE),
                 skip=UnitExists(UnitTypeId.LAIR,
                                 include_pending=True,
                                 include_not_ready=True),
             ),
         ])
         # end of build hard order, switch to reactive play
     )
     super().__init__([opener, AutoOverLord()])
Esempio n. 6
0
    def __init__(self):
        """Build order steps to be combined."""
        extractor_trick = SequentialList([
            Step(
                RequiredSupply(14),
                StepBuildGas(1),
                skip=RequiredUnitExists(UnitTypeId.EXTRACTOR,
                                        include_killed=True,
                                        include_pending=True),
            ),
            Step(
                RequiredUnitExists(
                    UnitTypeId.EXTRACTOR,
                    1,
                    include_pending=True,
                    include_not_ready=True,
                ),
                ZergUnit(UnitTypeId.DRONE, to_count=14),
            ),
            # SequentialList will take care of making sure the drone was made
            Step(
                RequiredUnitExists(UnitTypeId.EXTRACTOR),
                CancelBuilding(UnitTypeId.EXTRACTOR, to_count=0),
                skip=RequiredUnitExists(
                    UnitTypeId.EXTRACTOR,
                    1,
                    include_killed=True,
                    include_not_ready=False,
                ),
            ),
        ])

        opening = SequentialList([
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=14)),
            Step(
                RequiredSupply(14),
                extractor_trick,
                skip=RequiredUnitExists(
                    UnitTypeId.EXTRACTOR,
                    1,
                    include_killed=True,
                    include_not_ready=False,
                ),
            ),
            ActExpand(2, priority=True, consider_worker_production=False),
            Step(
                RequiredAll([RequiredSupply(14),
                             RequiredMinerals(130)]),
                StepBuildGas(1),
            ),
            Step(None, ZergUnit(UnitTypeId.DRONE, to_count=14)),
            Step(RequiredSupply(14), ActBuilding(UnitTypeId.SPAWNINGPOOL)),
            Step(
                RequiredAll([
                    RequiredUnitExists(UnitTypeId.HATCHERY),
                    RequiredUnitExists(UnitTypeId.SPAWNINGPOOL)
                ]),
                ZergUnit(UnitTypeId.QUEEN, 2),
            ),
            # spam lings
            Step(RequiredUnitExists(UnitTypeId.SPAWNINGPOOL),
                 ZergUnit(UnitTypeId.ZERGLING, 999)),
        ])

        ling_speed = BuildOrder([
            Step(
                RequiredAll([
                    RequiredUnitExists(UnitTypeId.SPAWNINGPOOL),
                    RequiredGas(100)
                ]),
                ActTech(UpgradeId.ZERGLINGMOVEMENTSPEED,
                        UnitTypeId.SPAWNINGPOOL),
            )
        ])

        worker_distribution = SequentialList([
            Step(
                RequiredSupply(15),
                PlanDistributeWorkers(),
                skip=RequiredUnitExists(
                    UnitTypeId.HATCHERY,
                    2,
                    include_killed=True,
                ),
            ),
            Step(
                RequiredUnitExists(UnitTypeId.EXTRACTOR),
                PlanDistributeWorkers(min_gas=3),
                skip=RequiredAny([
                    RequiredTechReady(UpgradeId.ZERGLINGMOVEMENTSPEED,
                                      percentage=0.01),
                    RequiredGas(96)
                ]),
            ),
            Step(
                RequiredAny([
                    RequiredTechReady(UpgradeId.ZERGLINGMOVEMENTSPEED,
                                      percentage=0.01),
                    RequiredGas(96)
                ]),
                PlanDistributeWorkers(max_gas=0),
            ),
        ])

        overlords = BuildOrder([
            Step(
                None,
                AutoOverLord(),
                skip_until=RequiredUnitExists(UnitTypeId.SPAWNINGPOOL),
            )
        ])

        super().__init__([opening, ling_speed, worker_distribution, overlords])
Esempio n. 7
0
    def __init__(self):
        """Create the build order."""
        self.drone = ZergUnit(UnitTypeId.DRONE, to_count=0)
        self.queen = ZergUnit(UnitTypeId.QUEEN, to_count=3, priority=True)
        self.zergling = ZergUnit(UnitTypeId.ZERGLING, to_count=0)
        self.roach = ZergUnit(UnitTypeId.ROACH, to_count=0)
        self.ravager = MorphRavager(target_count=0)
        self.swarmhost = ZergUnit(UnitTypeId.SWARMHOSTMP, to_count=0)
        ling_scout = BuildOrder([Step(RequiredTime(4 * 60), LingScout(2, ScoutLocation.scout_enemy3()))])
        run_by = Step(
            RequiredTime(4 * 60), RunBy(UnitTypeId.ZERGLING, 8, 1)
        )
        units = BuildOrder(
            [
                Step(None, self.drone),
                Step(UnitExists(UnitTypeId.SPAWNINGPOOL), self.queen),
                Step(UnitExists(UnitTypeId.INFESTATIONPIT), self.swarmhost),
                Step(UnitExists(UnitTypeId.ROACHWARREN), self.roach),
                Step(UnitExists(UnitTypeId.ROACH), self.ravager),
                Step(UnitExists(UnitTypeId.SPAWNINGPOOL), self.zergling),
            ]
        )
        self.gas = StepBuildGas(to_count=0)
        tech_buildings = BuildOrder(
            Step(
                UnitExists(UnitTypeId.DRONE, 30),
                BuildOrder(
                    [
                        Step(None, ActBuilding(UnitTypeId.ROACHWARREN)),
                        Step(None, MorphLair()),
                        Step(
                            RequiredAll(
                                [
                                    UnitExists(UnitTypeId.LAIR),
                                    UnitExists(UnitTypeId.EVOLUTIONCHAMBER),
                                    UnitExists(UnitTypeId.HATCHERY, 3),
                                ]
                            ),
                            ActBuilding(UnitTypeId.INFESTATIONPIT),
                        ),
                        Step(None, ActBuilding(UnitTypeId.EVOLUTIONCHAMBER)),
                        Step(UnitExists(UnitTypeId.HATCHERY, 4), ActBuilding(UnitTypeId.EVOLUTIONCHAMBER, 2)),
                    ]
                ),
            )
        )
        bases = BuildOrder(
            [
                Step(None, ActExpand(to_count=3, priority=True, consider_worker_production=False)),
                Step(UnitExists(UnitTypeId.DRONE, 60), ActExpand(4, priority=True, consider_worker_production=False)),
            ]
        )

        nat_spines = Step(
            UnitExists(UnitTypeId.SPAWNINGPOOL),
            NatSpines(4),
            skip=UnitExists(UnitTypeId.SPINECRAWLER, count=4),
            skip_until=lambda k: k.build_detector.rush_detected,
        )
        super().__init__(
            [
                nat_spines,
                units,
                tech_buildings,
                self.gas,
                bases,
                MassExpand(),
                AutoOverLord(),
                StandardUpgrades(),
                # ling_scout,
                run_by,
            ]
        )
Esempio n. 8
0
    async def create_plan(self) -> BuildOrder:
        queens_manager = self._bot.knowledge.get_manager(QueensSc2Manager)

        # Policies originally from QueenBot: https://aiarena.net/bots/201/
        early_game_queen_policy = {
            "creep_queens": {
                "active": True,
                "distance_between_queen_tumors": 3,
                "first_tumor_position": self._bot.zone_manager.own_natural.center_location.towards(
                    self._bot.game_info.map_center, 9
                ),
                "priority": True,
                "prioritize_creep": lambda: True,
                "max": 2,
                "defend_against_ground": True,
                "rally_point": self._bot.zone_manager.own_natural.center_location,
                "priority_defence_list": {
                    UnitTypeId.ZERGLING,
                    UnitTypeId.MARINE,
                    UnitTypeId.ZEALOT
                },
            },
            "creep_dropperlord_queens": {
                "active": True,
                "priority": True,
                "max": 1,
                "pass_own_threats": True,
                "target_expansions": [
                    el[0] for el in self._bot.expansion_locations_list[-6:-3]
                ],
            },
            "defence_queens": {
                "attack_condition": lambda: self._bot.enemy_units.filter(
                    lambda u: u.type_id == UnitTypeId.WIDOWMINEBURROWED
                              and u.distance_to(self._bot.enemy_start_locations[0]) > 50
                              and not queens_manager.queens.defence.enemy_air_threats
                              and not queens_manager.queens.defence.enemy_ground_threats
                )
                                            or (
                                                self._bot.structures(UnitTypeId.NYDUSCANAL)
                                                and self._bot.units(UnitTypeId.QUEEN).amount > 25
                                            ),
                "rally_point": self._bot.zone_manager.own_natural.center_location,
            },
            "inject_queens": {
                "active": True,
                "priority": False,
                "max": 2,
                "priority_defence_list": {
                    UnitTypeId.BATTLECRUISER,
                    UnitTypeId.LIBERATOR,
                    UnitTypeId.LIBERATORAG,
                    UnitTypeId.VOIDRAY,
                },
            },
            "nydus_queens": {
                "active": True,
                "max": 12,
                "steal_from": {QueenRoles.Defence},
            },
        }

        mid_game_queen_policy = {
            "creep_queens": {
                "max": 2,
                "priority": True,
                "defend_against_ground": True,
                "distance_between_queen_tumors": 3,
                "priority_defence_list": {
                    UnitTypeId.BATTLECRUISER,
                    UnitTypeId.LIBERATOR,
                    UnitTypeId.LIBERATORAG,
                    UnitTypeId.VOIDRAY,
                },
            },
            "creep_dropperlord_queens": {
                "active": True,
                "priority": True,
                "max": 1,
                "pass_own_threats": True,
                "priority_defence_list": set(),
                "target_expansions": [
                    el for el in self._bot.expansion_locations_list
                ],
            },
            "defence_queens": {
                "attack_condition": lambda: (
                                                sum([unit.energy for unit in self._bot.units(UnitTypeId.QUEEN)])
                                                / self._bot.units(UnitTypeId.QUEEN).amount
                                                >= 75
                                                and self._bot.units(UnitTypeId.QUEEN).amount > 40
                                            )
                                            or self._bot.enemy_units.filter(
                    lambda u: u.type_id == UnitTypeId.WIDOWMINEBURROWED
                              and u.distance_to(self._bot.enemy_start_locations[0]) > 50
                              and not queens_manager.queens.defence.enemy_air_threats
                              and not queens_manager.queens.defence.enemy_ground_threats
                )
                                            or self._bot.structures(UnitTypeId.NYDUSCANAL),
                "rally_point": self._bot.zone_manager.own_natural.center_location,
            },
            "inject_queens": {"active": False},
            "nydus_queens": {
                "active": True,
                "max": 12,
                "steal_from": {QueenRoles.Defence},
            },
        }

        gas_workers = 4
        build_drones = lambda ai: self._bot.workers.amount >= self._bot.townhalls.amount * 16 + gas_workers \
                                  or self._bot.workers.amount >= 16 * 3 + gas_workers  # max 3 base saturation

        upgrades = [
            Step(UnitReady(UnitTypeId.EVOLUTIONCHAMBER, 1),
                 Tech(UpgradeId.ZERGMISSILEWEAPONSLEVEL1, UnitTypeId.EVOLUTIONCHAMBER)),
            Tech(UpgradeId.ZERGGROUNDARMORSLEVEL1, UnitTypeId.EVOLUTIONCHAMBER),
            Tech(UpgradeId.ZERGMISSILEWEAPONSLEVEL2, UnitTypeId.EVOLUTIONCHAMBER),
            Tech(UpgradeId.ZERGGROUNDARMORSLEVEL2, UnitTypeId.EVOLUTIONCHAMBER),
            Tech(UpgradeId.ZERGMISSILEWEAPONSLEVEL3, UnitTypeId.EVOLUTIONCHAMBER),
            Tech(UpgradeId.ZERGGROUNDARMORSLEVEL3, UnitTypeId.EVOLUTIONCHAMBER),
        ]

        return BuildOrder(
            SetQueensSc2Policy(early_game_queen_policy, policy_name="early_game_queen_policy"),
            ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 13),
            ActUnit(UnitTypeId.OVERLORD, UnitTypeId.LARVA, 1),
            ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 14),
            Expand(2),
            ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA, 16),
            ActBuilding(UnitTypeId.SPAWNINGPOOL, 1),
            ActUnit(UnitTypeId.OVERLORD, UnitTypeId.LARVA, 2),
            SequentialList(
                Step(None, SetQueensSc2Policy(mid_game_queen_policy, policy_name="mid_game_queen_policy"),
                     skip_until=lambda ai: ai.time > 480),
                BuildOrder(
                    Step(None, DistributeWorkers(max_gas=4), skip=TechReady(UpgradeId.ZERGGROUNDARMORSLEVEL3, 0.01)),
                    Step(None, DistributeWorkers(max_gas=0),
                         skip_until=TechReady(UpgradeId.ZERGGROUNDARMORSLEVEL3, 0.01)),
                ),
                Step(None, SpeedMining(), lambda ai: ai.client.game_step > 5),
                AutoOverLord(),
                BuildOrder(
                    Step(None, ActUnit(UnitTypeId.DRONE, UnitTypeId.LARVA), skip=build_drones),
                    Step(None, MorphLair(), skip_until=TechReady(UpgradeId.ZERGGROUNDARMORSLEVEL1, 0.5)),
                    Step(None, ActBuilding(UnitTypeId.INFESTATIONPIT),
                         skip_until=TechReady(UpgradeId.ZERGGROUNDARMORSLEVEL2, 0.01)),
                    Step(None, MorphHive(), skip_until=TechReady(UpgradeId.ZERGGROUNDARMORSLEVEL2, 0.5)),
                    Step(None, ActUnit(UnitTypeId.QUEEN, UnitTypeId.HATCHERY)),
                    Expand(4),  # 4 mining bases
                    BuildGas(2),
                    ActBuilding(UnitTypeId.EVOLUTIONCHAMBER, 2),
                    upgrades,
                    ActBuilding(UnitTypeId.HATCHERY, 20),
                )
            ),
        )