sc2 python, ошибка утверждения: неподдерживаемая плотность пикселей

#python #starcraftgym

#python #starcraftgym

Вопрос:

Вот мой код, который я хочу запустить

 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>
  

Ответ №1:

Я столкнулся с той же проблемой, что и вы. Я закомментировал следующую строку:

assert self.bits_per_pixel % 8 == 0, "Unsupported pixel density"

внутри pixel_map.py .

Теперь карта загружается правильно.