【问题标题】:Starcraft starts with python-sc2 but nothing happens after the loading screen星际争霸以 python-sc2 启动,但加载屏幕后没有任何反应
【发布时间】:2019-10-29 21:43:54
【问题描述】:

作为一项学习练习,我一直在尝试构建一个 CNN 来玩星际争霸。 下面的代码是我正在尝试运行的示例。但是,当游戏开始时,我可以看到游戏窗口正在加载地图(不显示图片),但是当它完成加载时,屏幕关闭,之后什么也没有发生。

有人经历过类似的事情吗?

我在 python 3.7.3 和 sc2 0.11.1 中使用 spyder 我已按照https://github.com/Dentosal/python-sc2 上的说明进行操作。

我的系统是:/n 窗口 10 专业版 64 位 Intel i7-8700K CPI 6 核(12 个逻辑处理器)@ 3.7GHz 32GB 内存 英伟达 GeFORCE GTX 1080 GPU C 盘 326GB 免 464GB D 盘 931 GB

我可以自己运行游戏,所以我认为这与硬件无关。

import sc2

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

class MyBot(sc2.BotAI):
    async def on_step(self, iteration):
        await self.distribute_workers()

run_game(maps.get('AbyssalReefLE'), [Bot(Race.Protoss, 
                                     MyBot()),
                                     Computer(Race.Terran, Difficulty.Easy)], 
        realtime = True)

我希望游戏打开并且探测器开始收集资源。

但是,当代码执行时,我收到以下运行时错误:

File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\asyncio\base_events.py", line 526, in run_forever
    raise RuntimeError('This event loop is already running')

RuntimeError: This event loop is already running

即使在重新启动后也是如此。如果我再次尝试运行代码,我会得到以下信息:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<_host_game() done, defined at C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\main.py:221> exception=ValueError('3794 is not a valid AbilityId')>
ValueError: 3794 is not a valid AbilityId

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\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 "C:\Users\wizha\Anaconda3\envs\starcraft\lib\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 "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\main.py", line 91, in _play_game_ai
    game_data = await client.get_game_data()
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\client.py", line 143, in get_game_data
    return GameData(result.data)
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\game_data.py", line 29, in __init__
    self.abilities = {a.ability_id: AbilityData(self, a) for a in data.abilities if a.ability_id in ids}
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\game_data.py", line 29, in <dictcomp>
    self.abilities = {a.ability_id: AbilityData(self, a) for a in data.abilities if a.ability_id in ids}
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\game_data.py", line 94, in __init__
    assert self.id != 0
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\site-packages\sc2\game_data.py", line 102, in id
    return AbilityId(self._proto.remaps_to_ability_id)
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\enum.py", line 310, in __call__
    return cls.__new__(cls, value)
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\enum.py", line 564, in __new__
    raise exc
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\enum.py", line 548, in __new__
    result = cls._missing_(value)
  File "C:\Users\wizha\Anaconda3\envs\starcraft\lib\enum.py", line 577, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 3794 is not a valid AbilityId
ERROR:asyncio:Unclosed connection
client_connection: Connection<ConnectionKey(host='127.0.0.1', port=24418, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=None)>
INFO:sc2.protocol:Client status changed to Status.launched (was None)
INFO:sc2.controller:Creating new game
INFO:sc2.controller:Map:     AbyssalReefLE
INFO:sc2.controller:Players: Bot(Race.Protoss, <__main__.DukeBot object at 0x0000021E27D7A860>), Computer(Race.Terran, Difficulty.Easy)
INFO:sc2.protocol:Client status changed to Status.init_game (was Status.launched)
INFO:sc2.protocol:Client status changed to Status.in_game (was None)
INFO:root:Player id: 1 (None)
INFO:sc2.sc2process:kill_switch: Process cleanup
INFO:sc2.sc2process:Cleaning up...
INFO:sc2.sc2process:Cleanup complete
INFO:sc2.sc2process:Cleaning up...
INFO:sc2.sc2process:Cleanup complete
INFO:sc2.sc2process:Cleaning up...
INFO:sc2.sc2process:Cleanup complete
INFO:sc2.sc2process:Cleaning up...
INFO:sc2.sc2process:Cleanup complete

提前谢谢你

【问题讨论】:

    标签: python runtime


    【解决方案1】:

    我遇到了同样的错误,游戏的当前版本无法与 modul.compact. 有一个关于它的线程:https://github.com/Dentosal/python-sc2/issues/283 还有一个如何消除错误的说明,它对我有用,所以希望它也能帮助你。

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多