作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为学习练习,我一直在尝试构建一个 CNN 来玩《星际争霸》。下面的代码是我尝试运行的示例。但是,当游戏开始时,我可以看到游戏窗口正在加载 map (不显示图片),但是当它加载完成时,屏幕关闭,之后什么也没有发生。
有人经历过类似的事情吗?
我正在将spyder与python 3.7.3和sc2 0.11.1一起使用我已按照 https://github.com/Dentosal/python-sc2 上的说明进行操作言归正传。
我的系统是:/nWindows 10 专业版 64 位Intel i7-8700K CPI 6 核(12 个逻辑处理器)@ 3.7GHz32GB内存英伟达 GeFORCE GTX 1080 GPUC盘326GB 不含464GBD盘931GB
我可以自己运行游戏,所以我认为这与硬件无关。
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
提前谢谢
最佳答案
我有同样的错误,游戏的当前版本与模块不兼容。有一个关于它的线程:https://github.com/Dentosal/python-sc2/issues/283还有一个如何删除错误的说明,它对我有用,所以希望它也能帮助你。
关于python - 《星际争霸》以 python-sc2 启动,但加载屏幕后没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56611966/
我是一名优秀的程序员,十分优秀!