예제 #1
0
def main():
    run_game(maps.get("HonorgroundsLE"), [
        #Human(Race.Terran),
        Bot(Race.Terran, Cortana()),
        Computer(Race.Zerg, Difficulty.Medium)
    ], realtime=True)
def main():
    sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
        Bot(Race.Protoss, ThreebaseVoidrayBot()),
        Computer(Race.Protoss, Difficulty.Easy)
    ],
                 realtime=False)
예제 #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):
        for r in self.units(RAVAGER).idle:
            abilities = await self.get_available_abilities(r)
            if AbilityId.EFFECT_CORROSIVEBILE in abilities:
                await self.do(
                    r(EFFECT_CORROSIVEBILE,
                      self.find_target(self.state).position))

        if self.units(RAVAGER).amount > 20:
            for r in self.units(RAVAGER).idle:
                await self.do(r.attack(self.find_target(self.state)))

        elif self.units(RAVAGER).amount > 3:
            if len(self.known_enemy_units) > 0:
                for r in self.units(RAVAGER).idle:
                    await self.do(r.attack(self.find_target(self.state)))


run_game(maps.get("AbyssalReefLE"),
         [Bot(Race.Zerg, ZergAI()),
          Computer(Race.Terran, Difficulty.Medium)],
         realtime=False)
예제 #4
0
        else:
            return self.enemy_start_locations[0]

    async def attack(self):

        army_units = {STALKER: [15, 5], VOIDRAY: [8, 3]}

        for UNIT_NAME in army_units:
            if self.units(UNIT_NAME
                          ).amount > army_units[UNIT_NAME][0] and self.units(
                              UNIT_NAME).amount > army_units[UNIT_NAME][1]:
                for u in self.units(UNIT_NAME).idle:
                    await self.do(u.attack(self.find_target(self.state)))

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

    async def expand(self):
        if self.units(NEXUS).amount < (
                self.iteration /
                self.ITERATIONS_PER_MINUTE) and self.can_afford(NEXUS):
            await self.expand_now()


run_game(maps.get("AbyssalReefLE"),
         [Bot(Race.Protoss, dumbot()),
          Computer(Race.Terran, Difficulty.Hard)],
         realtime=False)
예제 #5
0
            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)
예제 #6
0
        # Check if we already have Barracks
        if self.structures(UnitTypeId.BARRACKS):
            # Check if we can afford to bui a Marine unit
            if (self.can_afford(UnitTypeId.MARINE)):
                # Get the first Barracks structure
                barracks = self.structures(UnitTypeId.BARRACKS).first

                # Train a Marine unit
                barracks.train(UnitTypeId.MARINE)

        # Check if we have at least 5 Marine units that are doing nothing
        if self.units(UnitTypeId.MARINE).idle.amount >= 5:
            # Send all of them to attack the enemy base
            for unit in self.units(UnitTypeId.MARINE).idle:
                unit.attack(self.enemy_start_locations[0])


# Here is where the war starts: your bot vs te computer in an Easy setting
sc2.run_game(
    sc2.maps.get("AcropolisLE"),  # The map is defined here
    [
        Bot(sc2.Race.Terran, MyBot()),
        Computer(sc2.Race.Terran, sc2.Difficulty.Easy)
    ],
    realtime=False,  # This makes the game run faster
    game_time_limit=
    3600  # This sets the time limit in seconds before declaring a tie
    # In fast mode 1 real minute equals to 10 game minutes, so
    # we set the limit to 1 game hour (6 real minutes)
)
예제 #7
0
        #     await self.upgrade_zergling_power3()
        #     await self.upgrade_zergling_defense3()
        await self.build_workers()
        # await self.build_hydralisk_den()
        # await self.create_queen()
        # await self.spawn_anti_air()
        await self.spawn_overlord()
        await self.build_spawning_pool()
        await self.spawn_zergling()
        await self.distribute_workers()
        await self.expand()
        # await self.populate_gas()
        if self.extractor_started < 3:
            await self.build_extractor()
        await self.zergling_attack()





    
# human v bot
# run_game(maps.get("(ƒ2)AcidPlantLE"), [
# Bot(Race.Terran, Human()),Bot(Race.Zerg, JoeBot())], realtime=True)

# bot v ai
run_game(maps.get("(2)AcidPlantLE"), [
Bot(Race.Zerg, JoeBot()), Computer(Race.Terran, Difficulty.Medium)], realtime=True)


예제 #8
0
            for star in self.units(STARGATE).ready.noqueue:
                if self.can_afford(VOIDRAY):
                    await self.do(star.train(VOIDRAY))

    async def command_army(self,params):           
        if (self.units(ZEALOT).idle.amount + self.units(STALKER).idle.amount )> params['attack_grp']:
            for u in self.units(ZEALOT).idle + self.units(STALKER).idle + self.units(VOIDRAY).idle:
                if len(self.known_enemy_units) == 0:
                    await self.do(u.attack(self.enemy_start_locations[0]))
                else:
                    await self.do(u.attack(self.known_enemy_units.prefer_close_to(u.position)[0].position))
        elif any([len(self.known_enemy_units.closer_than(15.0,nx)) > 0 for nx in self.units(NEXUS)]):
            for u in self.units(ZEALOT).idle + self.units(STALKER).idle + self.units(VOIDRAY).idle:
                await self.do(u.attack(self.known_enemy_units.prefer_close_to(u.position)[0].position))

    async def try_chronoboosting(self):
        for nx in self.units(NEXUS).ready:
            if nx.energy >=50:
                if self.units(GATEWAY).ready.amount ==0:
                    if not nx.has_buff(BuffId.CHRONOBOOSTENERGYCOST):
                        await self.do(nx(AbilityId.EFFECT_CHRONOBOOSTENERGYCOST, nx))
                else:
                    for gt in self.units(GATEWAY).ready:
                        if len(gt.orders)>0 and not gt.has_buff(BuffId.CHRONOBOOSTENERGYCOST):
                            await self.do(nx(AbilityId.EFFECT_CHRONOBOOSTENERGYCOST, gt))




run_game(maps.get('AbyssalReefLE'),[Bot(Race.Protoss,Gregbot()),Computer(Race.Protoss,Difficulty.Hard)],realtime=False)
예제 #9
0
def main():
    run_game(maps.get("Abyssal Reef LE"), [
        Bot(Race.Protoss, WorkerRushBotTree()),
        Computer(Race.Zerg, Difficulty.Hard)
    ],
             realtime=True)
예제 #10
0
def main():
    run_game(maps.get("AutomatonLE"), [
        Bot(Race.Protoss, BlindBotV0()),
        Computer(Race.Terran, Difficulty.Easy)
    ],
             realtime=True)
예제 #11
0
파일: run.py 프로젝트: lladdy/CheatMoney
import sys

import sc2
from cheatmoney import run_ladder_game
from cheatmoney.cheatmoney import CheatMoney
from sc2 import Race, Difficulty
from sc2.player import Bot, Computer

bot = Bot(Race.Terran, CheatMoney())

# 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("AbyssalReefLE"),
            [
                bot,
                Computer(Race.Random, Difficulty.VeryHard),
                # Computer(Race.Random, Difficulty.VeryEasy)
            ],
            # Force same spawn every game
            random_seed=1000,
            realtime=False)
예제 #12
0
			await self.gas_control()
		if iteration % self.microInterval == 0:
			pass
		if iteration % self.unitTargetting == 0:
			self.attack_decision()

			await self.updating_unit_targetting()
		
		
		'''pos = await self.find_placement(SPAWNINGPOOL, townhallLocationFurthestFromOpponent, min_distance=6)
                    # pos = await self.find_placement(SPAWNINGPOOL, self.townhalls.ready.random.position.to2, min_distance=6)
                    if pos is not None:
                        drone = self.workers.closest_to(pos)
                        if self.can_afford(SPAWNINGPOOL):
                            err = await self.do(drone.build(SPAWNINGPOOL, pos))

        # townhall furthest away from enemy base - that is where i will make all the tech buildings
            townhallLocationFurthestFromOpponent = None
            if self.townhalls.ready.exists and self.known_enemy_structures.exists:
                townhallLocationFurthestFromOpponent = max([x.position.to2 for x in self.townhalls.ready], key=lambda x: x.closest(self.known_enemy_structures).distance_to(x))
            if townhallLocationFurthestFromOpponent is None and self.townhalls.ready.exists:
                townhallLocationFurthestFromOpponent = self.townhalls.ready.random.position.to2'''
	
#running the game:
# first parameter is the map
# second parameter is the list of players/bots
# third is whether the game should be in a realtime, or sped up
for i in range(1):
	print (i)
	run_game(maps.get("AbyssalReefLE"), [Bot(Race.Zerg, ZergBotV2()), Computer(Race.Random, Difficulty.Medium)], realtime = False)
예제 #13
0
import sys

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

from __init__ import run_ladder_game
from jack_bot import EarlyAggro

bot = Bot(Race.Zerg, EarlyAggro())
# 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...")
        random_map = random.choice([
            "AcidPlantLE", "BlueshiftLE", "CeruleanFallLE", "DreamcatcherLE",
            "FractureLE", "LostAndFoundLE"
        ])

        sc2.run_game(sc2.maps.get(random_map),
                     [bot, Computer(Race.Random, Difficulty.CheatMoney)],
                     realtime=False)
        # sc2.run_game(sc2.maps.get("drone_worker_defense"), [bot], realtime=True)
        # sc2.run_game(sc2.maps.get("drone_scout_defense"), [bot], realtime=True)
        # sc2.run_game(sc2.maps.get("test_anti_colossus"),[bot, Computer(Race.Protoss, Difficulty.CheatInsane)],realtime=True)
예제 #14
0
def main():
    sc2.run_game(sc2.maps.get("AutomatonLE"), [
        Bot(Race.Protoss, CannonRushBot(), name="CheeseCannon"),
        Computer(Race.Protoss, Difficulty.Medium)
    ],
                 realtime=False)
            if 0 <= len((self.units(FACTORYTECHLAB))) <= 1:
                if fp.add_on_tag == 0 and self.can_afford(FACTORYTECHLAB):
                    await self.do(fp.build(FACTORYTECHLAB))

    async def build_starport(self):
        pass

    async def build_upgrades(self):
        pass

    async def attack(self):
        if self.units(MARINE).idle.amount > 15:
            cg = ControlGroup(self.units(MARINE).idle)
            self.attack_groups.add(cg)

        for ac in list(self.attack_groups):
            alive_units = ac.select_units(self.units)
            if alive_units.exists and alive_units.idle.exists:
                target = self.known_enemy_structures.random_or(
                    self.enemy_start_locations[0]).position
                for marine in ac.select_units(self.units):
                    await self.do(marine.attack(target))
            else:
                self.attack_groups.remove(ac)


run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Terran, MarineRushBot()),
    Computer(Race.Protoss, Difficulty.Easy),
],
         realtime=False)
예제 #16
0
            if location:
                # now we "select" (or choose) the nearest worker to that found location
                w = self.select_build_worker(location)
                if w and self.can_afford(UnitTypeId.HATCHERY):
                    # the worker will be commanded to build the command center
                    error = await self.do(
                        w.build(UnitTypeId.HATCHERY, location))
                    if error:
                        print(error)
        #try:
        #if self.can_afford(HATCHERY) and not self.already_pending(HATCHERY):
        #await self.chat_send('trying to expand')
        #library is not working; gotta wait for python-sc2 to fix that.
        #https://github.com/Dentosal/python-sc2/issues/97
        #await self.expand_now()
        #except AssertionError:
        #print("AssertionError DAMNIT")

    #async def upgrades(self):
    #if self.minerals > 750 and self.vespene > 325:


#runs the actual game
run_game(
    maps.get("AbyssalReefLE"),
    [
        #Human(Race.Terran),
        Bot(Race.Zerg, HiveMind()),
        Computer(Race.Random, Difficulty.Medium)
    ],
    realtime=False)
예제 #17
0
    # 게임 정보
    parser.add_argument(
        '--map_name',
        type=str,
        default='sc2_data/maps/NCFellowship-2019_m1_v2',
        help='경진대회 기본 맵')
    # 옵션
    parser.add_argument(
        '--realtime',
        action='store_true',
        default=False,
        help='false일 때는 빠르게 게임이 실행됨')
    parser.add_argument(
        '--debug',
        action='store_true',
        default=False,
        help='bot을 생성할 때, debug 인자로 전달함')
    args = parser.parse_args()

    # map 정보 읽기
    try:
        game_map = maps.get(args.map_name)
    except (KeyError, FileNotFoundError):
        assert os.path.exists(
            args.map_name +'.SC2Map'), f"지도 파일을 찾을 수 없음!: {args.map_name}"
        game_map = args.map_name

    bots = [Bot(Race.Terran, SimpleCombatBot(debug=args.debug)), Computer(Race.Terran, Difficulty(3))]
    result = sc2.run_game(game_map, bots, realtime=args.realtime)
    print(result)
예제 #18
0
파일: run.py 프로젝트: Shangxz/sc2ai
import sc2, sys
from __init__ import run_ladder_game
from sc2 import Race, Difficulty
from sc2.player import Bot, Computer

# Load bot
from example_bot import ExampleBot
bot = Bot(Race.Random, ExampleBot())

# 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("AbyssalReefLE"), [
            bot,
            Computer(Race.Protoss, Difficulty.VeryHard)
        ], realtime=True)
예제 #19
0
def main():
    run_game(maps.get("AutomatonLE"), [
        Bot(Race.Protoss, SentdeBot()),
        Computer(Race.Protoss, Difficulty.Easy)], realtime=True) 
예제 #20
0
def main():
    sc2.run_game(sc2.maps.get("Abyssal Reef LE"), [
        Bot(Race.Terran, SlowBot()),
        Computer(Race.Protoss, Difficulty.Medium)
    ], realtime=False, step_time_limit=0.2)
예제 #21
0
#allmaps = ['Bandwidth', 'Ephemeron', 'PrimusQ9', 'Reminiscence', 'Sanglune', 'TheTimelessVoid', 'Urzagol'] # all maps
allmaps = [
    'Acropolis', 'Artana', 'CrystalCavern', 'DigitalFrontier', 'OldSunshine',
    'Treachery', 'Triton'
]  # all maps

#allmaps = ['CrystalCavern'] # wierd maps only

_difficulty = random.choice(
    [Difficulty.CheatInsane, Difficulty.CheatMoney, Difficulty.CheatVision])

_realtime = False

_difficulty = Difficulty.CheatInsane  #CheatInsane, CheatMoney, CheatVision
_opponent = random.choice([Race.Zerg, Race.Terran, Race.Protoss, Race.Random])
_opponent = Race.Terran

# 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(random.choice(allmaps)),
            [Bot(Race.Protoss, MyBot()),
             Computer(_opponent, _difficulty)],
            realtime=_realtime)
예제 #22
0
def main():
    sc2.run_game(sc2.maps.get("(2)CatalystLE"), [
        Bot(Race.Terran, RampWallBot()),
        Computer(Race.Zerg, Difficulty.Easy)
    ],
                 realtime=True)
예제 #23
0
import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

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

from Main import RoachRush
bot = Bot(Race.Zerg, RoachRush())

# Start game
if __name__ == "__main__":
    sc2.run_game(
        sc2.maps.get("AcolyteLE"),
        [
            bot,
            Computer(Race.Protoss, Difficulty.Hard),
        ],
        realtime=False,
    )
예제 #24
0
def main():
    sc2.run_game(sc2.maps.get("ProximaStationLE"), [
        Bot(Race.Terran, TestBot()),
        Computer(Race.Zerg, Difficulty.Medium)
    ], realtime=False)
예제 #25
0
    async def build_offensive_force(self):
        for gw in self.units(GATEWAY).ready.noqueue:
            if self.can_afford(STALKER) and not self.already_pending(STALKER):
                await self.do(gw.train(STALKER))

    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):
        if self.units(STALKER).amount > 15:
            for s in self.units(STALKER).idle:
                await self.do(s.attack(self.find_target(self.state)))

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


run_game(
    maps.get("AbyssalReefLE"),
    [Bot(Race.Protoss, SpartaBot()),
     Computer(Race.Terran, Difficulty.Easy)],
    realtime=False)
예제 #26
0
                await self.do(queen(EFFECT_INJECTLARVA, hatchery))

    async def build_overlords(self):
        if self.supply_left < 9 and not self.already_pending(OVERLORD):
            larvae = self.units(LARVA).ready.noqueue
            for larva in larvae:
                if self.can_afford(OVERLORD):
                    await self.do(larva.train(OVERLORD))

    async def build_extractor(self):
        for hatchery in self.units(HATCHERY).ready:
            vespene = self.state.vespene_geyser.closer_than(15.0, hatchery)
            for v in vespene:
                if not self.can_afford(EXTRACTOR):
                    break
                worker = self.select_build_worker(v.position)
                if worker is None:
                    break
                if not self.units(EXTRACTOR).closer_than(1.0, v).exists:
                    await self.do(worker.build(EXTRACTOR, v))

    async def expand(self):
        if self.townhalls.amount < 3 and self.can_afford(HATCHERY):
            await self.expand_now()
    

run_game(maps.get("AbyssalReefLE"), [
    Bot(Race.Zerg, Legion()),
    Computer(Race.Zerg, Difficulty.Hard)
    ], realtime = False)
예제 #27
0
                        if not self.reaperlasttarget[reaper.tag].health > 0:
                            self.reaperrewards[reaper.tag] += 2000
                            del self.reaperlasttarget[reaper.tag]
                        #reward for a unit maimed
                        elif self.reaperlasttarget[
                                reaper.
                                tag].health < self.reaperlasttargethealth[
                                    reaper.tag]:
                            self.reaperrewards[reaper.tag] += .1 * (
                                self.reaperlasttargethealth[reaper.tag] -
                                self.reaperlasttarget[reaper.tag].health)

                    #resetting sentinel dictionaries
                    if len(self.enemyreward.values()) > 0:
                        self.reaperlasttarget[reaper.tag] = selectedtarget
                        self.reaperlasttargethealth[
                            reaper.tag] = selectedtarget.health
                        self.reaper_health[reaper.tag] = reaper.health
            #if we don't have enough units to feasably continue the fight run back home
            else:
                for reaper in ac.select_units(self.units):
                    await self.do(reaper.move(cc.position))
                self.attack_groups.remove(ac)

run_game(maps.get("Simple64"), [
    Bot(Race.Terran, RolloutBot([1, 1, 1])),
    Computer(Race.Protoss, Difficulty.Medium)
],
         realtime=False,
         save_replay_as="GeneticBotEASY2.SC2Replay")
def main():

    maps = [
        "16-BitLE",
        "AbiogenesisLE",
        "AbyssalReefLE",
        "AcidPlantLE",
        "AcolyteLE",
        "Acropolis",
        "AcropolisLE",
        "Artana",
        "AscensiontoAiurLE",
        "AutomatonLE",
        "BackwaterLE",
        "Bandwidth",
        "BattleontheBoardwalkLE",
        "BelShirVestigeLE",
        "BlackpinkLE",
        "BloodBoilLE",
        "BlueshiftLE",
        "CactusValleyLE",
        "CatalystLE",
        "CeruleanFallLE",
        "CrystalCavern",
        "CyberForestLE",
        "DarknessSanctuaryLE",
        "DeathAuraLE",
        "DefendersLandingLE",
        "DigitalFrontier",
        "DiscoBloodbathLE",
        "DreamcatcherLE",
        "EastwatchLE",
        "Ephemeron",
        "EphemeronLE",
        "EternalEmpireLE",
        "EverDreamLE",
        "FractureLE",
        "FrostLE",
        "GoldenWallLE",
        "HonorgroundsLE",
        "IceandChromeLE",
        "InterloperLE",
        "KairosJunctionLE",
        "KingsCoveLE",
        "LostandFoundLE",
        "MechDepotLE",
        "NeonVioletSquareLE",
        "NewkirkPrecinctTE",
        "NewRepugnancyLE",
        "NightshadeLE",
        "OdysseyLE",
        "OldSunshine",
        "PaladinoTerminalLE",
        "ParaSiteLE",
        "PillarsofGoldLE",
        "PortAleksanderLE",
        "PrimusQ9",
        "ProximaStationLE",
        "RedshiftLE",
        "Reminiscence",
        "Sanglune",
        "SequencerLE",
        "SimulacrumLE",
        "SubmarineLE",
        # "StasisLE", Commented out because it has uneven number of expansions, and wasn't used in the ladder pool anyway
        "TheTimelessVoid",
        "ThunderbirdLE",
        "Treachery",
        "Triton",
        "Urzagol",
        "WintersGateLE",
        "WorldofSleepersLE",
        "YearZeroLE",
        "ZenLE",
    ]

    for map_ in maps:
        try:
            bot = ExporterBot()
            bot.map_name = map_
            file_path = bot.get_pickle_file_path()
            if os.path.isfile(file_path):
                logger.warning(
                    f"Pickle file for map {map_} was already generated. Skipping. If you wish to re-generate files, please remove them first."
                )
                continue
            sc2.run_game(
                sc2.maps.get(map_), [Bot(Race.Terran, bot), Computer(Race.Zerg, Difficulty.Easy)], realtime=False
            )
        except ProtocolError:
            # ProtocolError appears after a leave game request
            pass
        except Exception as e:
            logger.warning(
                f"Map {map_} could not be found, so pickle files for that map could not be generated. Error: {e}"
            )
예제 #29
0
def main():
    run_game(maps.get("AutomatonLE"), [
        Bot(Race.Protoss, SentdeBot()),
        Computer(Race.Protoss, Difficulty.Medium)
    ],
             realtime=False)  # realtime设为False可以加速
    hm_game = 1
    win_counter = 0
    difficulty = Difficulty.Harder
    races = [Race.Zerg, Race.Terran, Race.Protoss]
    ennemie_is_stats_model = True

    for _ in range(hm_game):
        result = sc2.run_game(sc2.maps.get("AbyssalReefLE"), [
            Bot(JarexProtossQUnitsAttack.BOTRACE,
                JarexProtossQUnitsAttack(),
                name=JarexProtossQUnitsAttack.BOTNAME),
            Bot(JarexProtoss.BOTRACE,
                JarexProtoss(use_model=False,
                             human_control=False,
                             debug=False,
                             take_training_data=True,
                             epsilon=1.0),
                name=JarexProtoss.BOTNAME) if ennemie_is_stats_model else
            Computer(random.choice(races), difficulty)
        ],
                              realtime=False)

        if result == sc2.Result.Victory:
            win_counter += 1

    print(f"--- Training on {difficulty} Finished ---")
    print(f"win_counter: {win_counter}, game_counter: {hm_game}")
    print(f"ratio of game win: {win_counter / hm_game}")
    print(f"-" * 175)