Exemplo n.º 1
0
    def add_dummies(self, bot_dict: Dict[str, Tuple[Callable[[List[str]],
                                                             AbstractPlayer],
                                                    Optional[LadderZip]]]):
        bots: List[DummyBuilder] = [
            # Protoss
            DummyBuilder("4gate", "SharpRush", Race.Protoss, "gate4.py",
                         Stalkers4Gate),
            DummyBuilder("adept", "SharpShades", Race.Protoss,
                         "adept_allin.py", AdeptRush),
            DummyBuilder("cannonrush", "SharpCannons", Race.Protoss,
                         "cannon_rush.py", CannonRush),
            DummyBuilder("disruptor", "SharpSpheres", Race.Protoss,
                         "disruptor.py", SharpSphereBot),
            DummyBuilder("dt", "SharpShadows", Race.Protoss,
                         "dark_templar_rush.py", DarkTemplarRush),
            DummyBuilder("robo", "SharpRobots", Race.Protoss, "robo.py",
                         MacroRobo),
            DummyBuilder("stalker", "SharpSpiders", Race.Protoss,
                         "macro_stalkers.py", MacroStalkers),
            DummyBuilder("voidray", "SharpRays", Race.Protoss, "voidray.py",
                         MacroVoidray),
            DummyBuilder("zealot", "SharpKnives", Race.Protoss,
                         "proxy_zealot_rush.py", ProxyZealotRushBot),
            DummyBuilder("tempest", "SharpTempests", Race.Protoss,
                         "one_base_tempests.py", OneBaseTempests),
            # Zerg
            DummyBuilder("12pool", "BluntCheese", Race.Zerg, "twelve_pool.py",
                         TwelvePool),
            DummyBuilder("200roach", "BluntRoaches", Race.Zerg,
                         "macro_roach.py", MacroRoach),
            DummyBuilder("hydra", "BluntSpit", Race.Zerg, "roach_hydra.py",
                         RoachHydra),
            DummyBuilder("lings", "BluntTeeth", Race.Zerg, "lings.py",
                         LingFlood),
            DummyBuilder("macro", "BluntMacro", Race.Zerg, "macro_zerg_v2.py",
                         MacroZergV2),
            DummyBuilder("mutalisk", "BluntFlies", Race.Zerg, "mutalisk.py",
                         MutaliskBot),
            DummyBuilder("workerrush", "BluntWorkers", Race.Zerg,
                         "worker_rush.py", WorkerRush),
            DummyBuilder("lurker", "BluntLurkers", Race.Zerg, "lurkers.py",
                         LurkerBot),
            DummyBuilder("paul", "Paul", Race.Zerg, "Paul.py", PaulBot),
            # TODO: Not really a functional bot
            # DummyBuilder("spine", "BluntDefender", Race.Zerg, "spine_defender.py", SpineDefender),
            # TODO: Not really Sharpy bot
            # DummyBuilder("roachrush", "SharpShades", Race.Zerg, "adept_allin.py", RoachRush),
            # Terran
            DummyBuilder("banshee", "RustyScreams", Race.Terran, "banshees.py",
                         Banshees),
            DummyBuilder("bc", "FlyingRust", Race.Terran, "battle_cruisers.py",
                         BattleCruisers),
            DummyBuilder("bio", "RustyInfantry", Race.Terran, "bio.py",
                         BioBot),
            DummyBuilder("cyclone", "RustyLocks", Race.Terran, "cyclones.py",
                         CycloneBot),
            DummyBuilder("marine", "RustyMarines", Race.Terran,
                         "marine_rush.py", MarineRushBot),
            DummyBuilder("oldrusty", "OldRusty", Race.Terran, "rusty.py",
                         Rusty),
            DummyBuilder("tank", "RustyTanks", Race.Terran,
                         "two_base_tanks.py", TwoBaseTanks),
            DummyBuilder("terranturtle", "RustyOneBaseTurtle", Race.Terran,
                         "one_base_turtle.py", OneBaseTurtle),
        ]

        for bot in bots:
            bot_dict[bot.key] = bot.build_definition()

        not_buildable = {
            "lingflood": (lambda params: Bot(Race.Zerg, LingFlood(False))),
            "lingspeed": (lambda params: Bot(Race.Zerg, LingFlood(True))),
            "randomzerg": (lambda params: Bot(Race.Zerg, RandomZergBot())),
            "randomprotoss":
            (lambda params: Bot(Race.Protoss, RandomProtossBot())),
            "randomterran":
            (lambda params: Bot(Race.Terran, RandomTerranBot())),
        }

        for key, func in not_buildable.items():
            # TODO: Solve this in a generic way!
            bot_dict[key] = (func, None)

        buildable_only = {
            "cannonrush_1":
            DummyZip("SharpCannonRush", "Protoss",
                     os.path.join("dummies", "protoss", "cannon_rush.py"),
                     "cannon_rush = 0"),
            "cannonrush_2":
            DummyZip("SharpCannonContain", "Protoss",
                     os.path.join("dummies", "protoss", "cannon_rush.py"),
                     "cannon_rush = 1"),
            "cannonrush_3":
            DummyZip("SharpCannonExpand", "Protoss",
                     os.path.join("dummies", "protoss", "cannon_rush.py"),
                     "cannon_rush = 2"),
            "marine_1":
            DummyZip("RustyMarines1", "Terran",
                     os.path.join("dummies", "terran", "marine_rush.py"),
                     "marine = 0"),
            "marine_2":
            DummyZip("RustyMarines2", "Terran",
                     os.path.join("dummies", "terran", "marine_rush.py"),
                     "marine = 1"),
            "marine_3":
            DummyZip("RustyMarines3", "Terran",
                     os.path.join("dummies", "terran", "marine_rush.py"),
                     "marine = 2"),
        }

        for key, dummy_zip in buildable_only.items():
            # TODO: Solve this in a generic way!
            bot_dict[key] = (None, dummy_zip)
Exemplo n.º 2
0
    def find_target(self, state):
        if len(self.known_enemy_units) > 0:
            return random.choice(self.known_enemy_units)
        elif len(self.known_enemy_structures) > 0:
            return random.choice(self.known_enemy_structures)
        else:
            return self.enemy_start_locations[0]


    async def send_the_attack(self):
        if self.units(ZERGLING).amount > 20:
            for s in self.units(ZERGLING).idle:
                await self.do(s.attack(self.find_target(self.state)))

        elif self.units(ZERGLING).amount > 8:
            if len(self.known_enemy_units) > 0:
                for s in self.units(ZERGLING).idle:
                    await self.do(s.attack(random.choice(self.known_enemy_units)))        



run_game(maps.get("CactusValleyLE"), [
    Bot(Race.Zerg, ZergyZergZergBot()),
    # Bot(Race.Zerg, ZergyZergZergBot()),
    Computer(Race.Random, Difficulty.Easy)
], realtime=False)



Exemplo n.º 3
0
    def find_target(self, state):
        if len(self.known_enemy_units) > 0:
            return random.choice(self.known_enemy_units)
        elif len(self.known_enemy_structures) > 0:
            return random.choice(self.known_enemy_structures)
        else:
            return self.enemy_start_locations[0]

    async def attack(self):
        # {UNIT: [n to fight, n to defend]}
        aggressive_units = {STALKER: [15, 5],
                            VOIDRAY: [8, 3]}


        for UNIT in aggressive_units:
            if self.units(UNIT).amount > aggressive_units[UNIT][0] and self.units(UNIT).amount > aggressive_units[UNIT][1]:
                for s in self.units(UNIT).idle:
                    await self.do(s.attack(self.find_target(self.state)))

            elif self.units(UNIT).amount > aggressive_units[UNIT][1]:
                if len(self.known_enemy_units) > 0:
                    for s in self.units(UNIT).idle:
                        await self.do(s.attack(random.choice(self.known_enemy_units)))


run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Protoss, SakethBot()),
    Computer(Race.Terran, Difficulty.Hard)
    ], realtime=False)
Exemplo n.º 4
0
def main():
    sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
        Bot(Race.Zerg, Hydralisk()),
        Computer(Race.Terran, Difficulty.Medium)
    ], realtime=False, save_replay_as="ZvT.SC2Replay")
Exemplo n.º 5
0
            if self.start_location.distance_to(
                    el) < self.EXPANSION_GAP_THRESHOLD:
                continue

            distance = await self.client.query_pathing(self.start_location, el)
            if distance:
                if distance < min_distance:
                    min_distance = distance
                    pos = el

        return pos

    def _select_worker(self, target: Point2) -> Optional[Unit]:
        workers: Units = self.workers.filter(
            lambda unit: not unit.is_carrying_minerals and unit.is_collecting)
        return (workers.closest_to(target) if workers else
                (self.workers.first if self.workers else None))


if __name__ == "__main__":
    # Local game
    random_map = random.choice(["EverDreamLE"])
    random_race = random.choice([Race.Zerg, Race.Terran, Race.Protoss])
    bot = Bot(Race.Zerg, ZergBot())
    run_game(
        maps.get(random_map),
        [bot, Computer(Race.Terran, Difficulty.Hard)],
        realtime=False,
        # save_replay_as="ZvTElite.SC2Replay",
    )
__author__ = "J. Smith"

import sc2
from sc2 import run_game, maps, Race, Difficulty
from sc2.player import Bot, Computer


class TerranBot(sc2.BotAI):
    async def on_step(self, iteration):
        # what to do every step
        await self.distribute_workers()  # in sc2/bot_ai.py


run_game(
    maps.get("KingsCoveLE"),
    [Bot(Race.Terran, TerranBot()),
     Computer(Race.Zerg, Difficulty.VeryEasy)],
    realtime=True)
Exemplo n.º 7
0
def main():
    sc2.run_game(sc2.maps.get("Marine Split Challenge"), [
        Bot(Race.Terran, MarineSplitChallenge()),
    ], realtime=False, save_replay_as="Example.SC2Replay")
Exemplo n.º 8
0
import sc2
from sc2 import run_game, maps, Race, Difficulty
from sc2.player import Bot, Computer


class WorkerRushBot(sc2.BotAI):
    async def on_step(self, iteration: int):
        if iteration == 0:
            for worker in self.workers:
                self.do(worker.attack(self.enemy_start_locations[0]))


run_game(maps.get("Abyssal Reef LE"), [
    Bot(Race.Zerg, WorkerRushBot()),
    Computer(Race.Protoss, Difficulty.Medium)
],
         realtime=True)
Exemplo n.º 9
0
    def find_target(self, state):
        if len(self.known_enemy_units) > 0:
            return random.choice(self.known_enemy_units)
        elif len(self.known_enemy_structures) > 0:
            return random.choice(self.known_enemy_structures)
        else:
            return self.enemy_start_locations[0]

    async def attack(self):
        # {UNIT: [n to fight, n to defend]}
        aggressive_units = {VOIDRAY: [8, 3]}

        for UNIT in aggressive_units:
            if self.units(UNIT).amount > aggressive_units[UNIT][
                    0] and self.units(UNIT).amount > aggressive_units[UNIT][1]:
                for s in self.units(UNIT).idle:
                    await self.do(s.attack(self.find_target(self.state)))

            elif self.units(UNIT).amount > aggressive_units[UNIT][1]:
                if len(self.known_enemy_units) > 0:
                    for s in self.units(UNIT).idle:
                        await self.do(
                            s.attack(random.choice(self.known_enemy_units)))


run_game(
    maps.get("AbyssalReefLE"),
    [Bot(Race.Protoss, SentdeBot()),
     Computer(Race.Terran, Difficulty.Hard)],
    realtime=False)
Exemplo n.º 10
0
	async def build_assimilator(self):
		# Сколько задействовано рабочих, сколько освоено гейзеров,
		# count = 0 
		# for pl in self.units(PYLON).ready:
		# 	count += 1 
		# 	print('\n')
		# 	print('Pylons :  --- >')
		# 	print(count)
		pl = self.units(PYLON).ready
		print(type(pl))
		print('\n')
		count = len(pl)
		print(count)
		if count >= 2:
			for nexus in self.units(NEXUS).ready:
				vgs = self.state.vespene_geyser.closer_than(20.0, nexus)
				for vg in vgs:
					if not self.can_afford(ASSIMILATOR):
						break
					elif not self.already_pending(ASSIMILATOR):
						if not self.units(ASSIMILATOR).closer_than(1.0, vg).exists:
							worker = self.select_build_worker(vg.position)
							await self.do(worker.build(ASSIMILATOR, vg))



run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Protoss, Tim()),
    Computer(Race.Terran, Difficulty.Easy)
], realtime=False)
Exemplo n.º 11
0
def main():
    sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [Human(Race.Terran), Bot(Race.Zerg, ZergRushBot())], realtime=True)
Exemplo n.º 12
0
"""Run the ladder or local game"""
import random
import sys
from sc2 import Race, Difficulty, AIBuild, run_game, maps
from sc2.player import Bot, Computer
from __init__ import run_ladder_game
from main import JackBot

if __name__ == "__main__":
    if "--LadderServer" in sys.argv:
        # Ladder game started by LadderManager
        print("Starting ladder game...")
        run_ladder_game(Bot(Race.Zerg, JackBot()))
    else:
        # Local game
        while True:
            MAP = random.choice([
                "BlueshiftLE", "KairosJunctionLE", "ParaSiteLE",
                "PortAleksanderLE"
            ])
            BUILD = random.choice([
                AIBuild.Macro, AIBuild.Rush, AIBuild.Timing, AIBuild.Power,
                AIBuild.Air
            ])
            DIFFICULTY = random.choice([
                Difficulty.CheatInsane, Difficulty.CheatVision,
                Difficulty.CheatMoney
            ])
            RACE = random.choice([Race.Protoss, Race.Zerg, Race.Terran])
            """ FINISHED_SETS = {
                BUILD == AIBuild.Air and DIFFICULTY == Difficulty.CheatVision and RACE == Race.Protoss,
Exemplo n.º 13
0
                    elif (err):
                        self.UnCreepable.append(BestPosition)
        #print(self.UnCreepable)
        #d = await self._client.query_pathing(th.position, el)

    async def Overlord_Control(self):

        for Overlord in range(len(self.units(OVERLORD).idle)):
            if (self.units(OVERLORD).idle[Overlord] not in self.OverlordsSent
                    and self.expansionLocationsSorted != []):
                print(len(self.expansionLocationsSorted))
                print(len(self.OverlordsSent))
                if (len(self.expansionLocationsSorted) > len(
                        self.OverlordsSent)):
                    Position = self.expansionLocationsSorted[len(
                        self.OverlordsSent)][0]
                    await self.do(
                        self.units(OVERLORD)[Overlord].attack(Position))
                    self.OverlordsSent.append(
                        self.units(OVERLORD)[Overlord].tag)

        for Position in self.RequestVisibilty:
            if Position not in self.PositionsVisibiltySent:
                await self.do(self.units(OVERLORD).idle[0].attack(Position))
                self.PositionsVisibiltySent.append(Position)


run_game(maps.get("AbyssalReefLE"),
         [Bot(Race.Zerg, SentdeBot()),
          Computer(Race.Terran, Difficulty.Easy)],
         realtime=False)
        if y > self.game_info.map_size[1]:
            y = self.game_info.map_size[1]
        res = position.Point2(position.Pointlike((x, y)))
        return res

    async def scout(self):
        if self.units(OBSERVER).amount > 0:
            scout = self.units(OBSERVER).random
            if scout.is_idle:
                enemy_location = self.enemy_start_locations[0]
                move_to = self.random_location_variance(enemy_location)
                await self.do(scout.move(move_to))
        elif self.units(OBSERVER).amount < 1:
            for rf in self.units(ROBOTICSFACILITY).ready.noqueue:
                if self.can_afford(OBSERVER):
                    await self.do(rf.train(OBSERVER))


for i in range(100):
    run_game(maps.get("AbyssalReefLE"), [
        Bot(Race.Protoss, MyProtossBot(use_model=True)),
        Computer(Race.Zerg, Difficulty.Medium)
    ],
             realtime=False)

run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Protoss, MyProtossBot()),
    Computer(Race.Terran, Difficulty.Hard)
],
         realtime=False)
Exemplo n.º 15
0
def main():
    run_game(maps.get("AbyssalReefLE"), [
        Bot(Race.Protoss, BinaryBot()),
        Computer(Race.Terran, Difficulty.Easy)
        ], realtime=False)
Exemplo n.º 16
0
def main():
    sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
        Bot(Race.Protoss, WarpGateBot()),
        Computer(Race.Protoss, Difficulty.Easy)
    ],
                 realtime=False)
Exemplo n.º 17
0
import sc2
from sc2.bot_ai import BotAI
from sc2.player import Bot, Computer


class MyBot(BotAI):
    async def on_step(self, iteration):
        # Put your bot's brain here
        print(f'This is my bot in iteration {iteration}!')


sc2.run_game(sc2.maps.get("AcropolisLE"), [
    Bot(sc2.Race.Terran, MyBot()),
    Computer(sc2.Race.Terran, sc2.Difficulty.Easy)
],
             realtime=False)
Exemplo n.º 18
0
            building = self._game_data.abilities[building.value]

        if await self.can_place(building, near):
            return near

        if max_distance == 0:
            return None

        for distance in range(placement_step, max_distance, placement_step):
            possible_positions = [Point2(p).offset(near).to2 for p in (
                    [(dx, -distance) for dx in range(-distance, distance + 1, placement_step)] +
                    [(dx, distance) for dx in range(-distance, distance + 1, placement_step)] +
                    [(-distance, dy) for dy in range(-distance, distance + 1, placement_step)] +
                    [(distance, dy) for dy in range(-distance, distance + 1, placement_step)]
            )]
            res = await self._client.query_building_placement(building, possible_positions)
            possible = [p for r, p in zip(res, possible_positions) if r == ActionResult.Success and not self.positionObstructionCalculator.doesPositionObstructWorkers(p)]
            if not possible:
                continue

            if random_alternative:
                return random.choice(possible)
            else:
                return min(possible, key=lambda p: p.distance_to(near))
        return None

run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Protoss, SentBot()),
    Computer(Race.Protoss, Difficulty.Medium)
], realtime=True)
Exemplo n.º 19
0
import sc2, sys
from __init__ import run_ladder_game
from sc2 import Race, Difficulty
from sc2.player import Bot, Computer

# Load bot
from CreepyBot import CreepyBot
bot = Bot(Race.Zerg, CreepyBot())

# Start game
if __name__ == '__main__':
    if "--LadderServer" in sys.argv:
        # Ladder game started by LadderManager
        print("Starting ladder game...")
        run_ladder_game(bot)
    else:
        # Local game
        print("Starting local game...")
        sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
            bot,
            Computer(Race.Protoss, Difficulty.VeryHard)
        ], realtime=True)
def main():
    run_game(maps.get("Abyssal Reef LE"), [
        Bot(Race.Zerg, WorkerRushBot()),
        Computer(Race.Protoss, Difficulty.Medium)
    ],
             realtime=True)
Exemplo n.º 21
0
                                REFINERY):
                    try:
                        vgs = self.state.vespene_geyser.closer_than(20.0, cc)
                        for vg in vgs:
                            if self.units(REFINERY).closer_than(1.0,
                                                                vg).exists:
                                break
                            worker = self.select_build_worker(vg.position)
                            await self.do(worker.build(REFINERY, vg))
                    except Exception as e:
                        pass

    async def build_scv(self):
        if self.units(SCV).amount <= MAX_WORKERS:
            for cc in self.units(COMMANDCENTER).ready.noqueue:
                if self.can_afford(SCV) and not self.already_pending(SCV):
                    await self.do(cc.train(SCV))

    async def build_supply_depot(self):
        SD = self.units(COMMANDCENTER)
        if self.supply_used > 0.7 * self.supply_cap:
            if self.can_afford(
                    SUPPLYDEPOT) and not self.already_pending(SUPPLYDEPOT):
                await self.build(SUPPLYDEPOT,
                                 near=SD.first.position.towards(
                                     self.main_base_ramp.top_center, 4))

run_game(maps.get("AbyssalReefLE"),
         [Bot(Race.Terran, NN()),
          Computer(Race.Terran, Difficulty.Medium)],
         realtime=False)
Exemplo n.º 22
0
                    if len(self.known_enemy_units) > 0:
                        target = self.known_enemy_units.closest_to(
                            random.choice(self.units(NEXUS)))

                elif choice == 2:
                    #attack enemy structures
                    if len(self.known_enemy_structures) > 0:
                        target = random.choice(self.known_enemy_structures)

                elif choice == 3:
                    #attack_enemy_start
                    target = self.enemy_start_locations[0]

                if target:
                    for vr in self.units(VOIDRAY).idle:
                        await self.do(vr.attack(target))

                y = np.zeros(4)
                y[choice] = 1
                #print(y)
                self.train_data.append([y, self.flipped])

            #print(len(self.train_data))


for i in range(100):
    run_game(maps.get("AbyssalReefLE"), [
        Bot(Race.Protoss, SentdeBot(use_model=True)),
        Computer(Race.Protoss, Difficulty.Medium),
    ],
             realtime=False)
Exemplo n.º 23
0
def main():
    run_game(maps.get("AutomatonLE"), [
        Bot(Race.Protoss, SentdeBot()),
        Computer(Race.Protoss, Difficulty.Easy)
    ],
             realtime=False)  # realtime设为False可以加速
Exemplo n.º 24
0
                    await self.do(s.take_action(random.choice(self.known_enemy_units)))

        # every 1000 game step we expand (build a new nexus)
        if not iteration % 1000:
            await self.expand_now()

    async def create_vaspene(self):
        # we build some assimilator to take other ressources
        for nexus in self.units(UnitTypeId.NEXUS).ready:
            vaspenes = self.state.vespene_geyser.closer_than(15.0, nexus)
            for vaspene in vaspenes:
                if not self.can_afford(UnitTypeId.ASSIMILATOR):
                    break
                worker = self.select_build_worker(vaspene.position)
                if worker is None:
                    break
                if not self.units(UnitTypeId.ASSIMILATOR).closer_than(1.0, vaspene).exists:
                    await self.do(worker.build(UnitTypeId.ASSIMILATOR, vaspene))


if __name__ == '__main__':

    # Notez que lors du premier run, deux erreurs l'un après l'autre interrompera le code.
    # Le premier vient de assert self.id != 0 à la ligne 93 de game_data, commentez le.
    # Le deuxième vient de assert self.bits_per_pixel % 8 == 0, "Unsupported pixel density" à la ligne 9 de pixel_map, commentez le.

    run_game(maps.get("AbyssalReefLE"), [
        Bot(TutoBot.BOTRACE, TutoBot()),
        Computer(Race.Zerg, Difficulty.Easy)
    ], realtime=False)
Exemplo n.º 25
0
                if choice == 0:  # no attack
                    wait = random.randrange(20, 165)
                    self.do_something_after = self.iteration + wait

                elif choice == 1:  # attack_unit_closest_nexus
                    if len(self.known_enemy_units) > 0:
                        target = self.known_enemy_units.closest_to(
                            random.choice(self.units(NEXUS)))

                elif choice == 3:  # attack enemy structures
                    if len(self.known_enemy_structures) > 0:
                        target = random.choice(self.known_enemy_structures)

                if target:
                    for vr in self.units(VOIDRAY).idle:
                        await self.do(vr.attack(target))

                y = np.zeros(4)
                y[choice] = 1
                #print(y)
                self.train_data.append([y, self.flipped])

            print(len(self.train_data))


run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Protoss, DabsonBot(use_model=True)),
    Computer(Race.Terran, Difficulty.Medium)
],
         realtime=False)
def main():
    sc2.run_game(sc2.maps.get('Abyssal Reef LE'), [
        Bot(Race.Protoss, ConstructorAgent()),
        Computer(Race.Protoss, difficulty=Difficulty.Hard)
    ],
                 realtime=True)
Exemplo n.º 27
0
        if len(self.known_enemy_units) > 0:
            return random.choice(self.known_enemy_units)
        elif len(self.known_enemy_structures) > 0:
            return random.choice(self.known_enemy_structures)
        else:
            return self.enemy_start_locations[0]

    async def attack(self):
        # {UNIT: [n to fight, n to defend]}
        aggressive_units = {VOIDRAY: [8, 3]}

        for UNIT in aggressive_units:
            unitCount = self.units(UNIT).amount
            offenceCount = aggressive_units[UNIT][0]
            defenceCount = aggressive_units[UNIT][1]
            idleUnits = self.units(UNIT).idle

            if unitCount > offenceCount and unitCount > defenceCount:
                for s in idleUnits:
                    await self.do(s.attack(self.find_target(self.state)))
            elif unitCount > defenceCount and len(self.known_enemy_units) > 0:
                for s in idleUnits:
                    await self.do(
                        s.attack(random.choice(self.known_enemy_units)))


run_game(
    maps.get("AbyssalReefLE"),
    [Bot(Race.Protoss, DabsonBot()),
     Computer(Race.Terran, Difficulty.Hard)],
    realtime=False)
Exemplo n.º 28
0
def main():
    sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
        # Human(Race.Terran),
        Bot(Race.Terran, ProxyRaxBot()),
        Computer(Race.Zerg, Difficulty.Easy)
    ], realtime=False)
def main():
    sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
        Bot(Race.Protoss, ResourceAgent()),
        Computer(Race.Protoss, Difficulty.Easy)
    ],
                 realtime=False)
Exemplo n.º 30
0
            if len(self.known_enemy_units) > 0:
                for stalker in self.units(STALKER).idle:
                    await self.do(
                        stalker.attack(random.choice(self.known_enemy_units)))

        if self.units(STALKER).amount > 15:
            for stalker in self.units(STALKER).idle:
                await self.do(stalker.attack(self.find_target(self.state)))

    def find_target(self, state):
        if len(self.known_enemy_units) > 0:
            return random.choice(self.known_enemy_units)
        elif len(self.known_enemy_structures) > 0:
            return random.choice(self.known_enemy_structures)
        else:
            return self.enemy_start_locations[0]


# zaczynamy nasza gre, wybieramy mape
run_game(
    maps.get("Abyssal reef LE"),
    [
        # wybranym 1 zawodnika np: Bot(Race.Protoss, sc2_lechita_1())
        # lub komputer np: Computer(Race.Protoss, Difficulty.Hard)
        Bot(Race.Protoss, sc2_lechita_1()),
        Computer(Race.Protoss, Difficulty.Easy)
        # tutaj wyberamy czas True - czas normalny
        # False - czas przyśpieszony
    ],
    realtime=False)