这是我要运行的代码
import sc2
from sc2 import run_game, maps, Race, Difficulty
from sc2. player import Bot, Computer
class pxk(sc2.BotAI):
async def on_step(self, iteration):
await self.distribute_workers()
run_game(maps.get("AbyssalReefLE"), [
Bot(Race.Terran, pxk()),
Computer(Race.Terran, Difficulty.Easy)
], realtime=True)
首先,它会运行,它会打开StarCraft II游戏窗口并加载游戏,然后在加载完成时关闭并抛出以下错误
Traceback (most recent call last):
File "starcraft-2.py", line 12, in <module>
], realtime=False)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/main.py", line 306, in run_game
_host_game(map_settings, players, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asynci o/base_events.py", line 468, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/main.py", line 233, in _host_game
result = await _play_game(players[0], client, realtime, portconfig, step_time_limit, game_time_limit, rgb_render_config)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/main.py", line 204, in _play_game
result = await _play_game_ai(client, player_id, player.ai, realtime, step_time_limit, game_time_limit)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/main.py", line 92, in _play_game_ai
game_info = await client.get_game_info()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/client.py", line 147, in get_game_info
return GameInfo(result.game_info)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/game_info.py", line 143, in __init__
self.pathing_grid: PixelMap = PixelMap(self._proto.start_raw.pathing_grid)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/sc2/pixel_map.py", line 9, in __init__
assert self.bits_per_pixel % 8 == 0, "Unsupported pixel density"
AssertionError: Unsupported pixel density
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10e443d30>
答案 0 :(得分:3)
我遇到了与您自己相同的问题。我注释了以下行:
assert self.bits_per_pixel % 8 == 0, "Unsupported pixel density"
在pixel_map.py
中。
地图现在可以正确加载了。