AI星际争霸安装环境

首先是要有python环境,然后

pip install --upgrade burnysc2得到代理库,

下载StarCraft2游戏,在文件目录创建一个Maps文件夹,将从https://github.com/Blizzard/s2client-proto#downloads下载到的地图文件放入Maps中

 

然后引用官方代码进行测试,报错

 

 

 

from sc2 import maps
from sc2.player import Bot, Computer
from sc2.main import run_game
from sc2.data import Race, Difficulty
from sc2.bot_ai import BotAI

class WorkerRushBot(BotAI):
    async def on_step(self, iteration: int):
        if iteration == 0:
            for worker in self.workers:
                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)

解决办法,加上

import nest_asyncio
nest_asyncio.apply()

然后就可以AI开始游戏了

 

posted @ 2022-07-16 18:09  caxi  阅读(149)  评论(0编辑  收藏  举报