import sc2
from sc2 import BotAI, Race
from sc2.player import Bot
class NoBot(BotAI):
async def on_step(self, iteration):
return
class ResignBot(BotAI):
async def on_step(self, iteration):
if iteration == 10:
await self._client.leave()
def main():
sc2.run_game(
sc2.maps.get("EverDream506"),
[Bot(Race.Random, ResignBot()), Bot(Race.Random, NoBot())],
realtime=False,
save_replay_as="test.SC2Replay"
)
if __name__ == "__main__":
main()
with trace:
Traceback (most recent call last):
File "resign.py", line 24, in <module>
main()
File "resign.py", line 16, in main
sc2.run_game(
File ".../sc2/main.py", line 596, in run_game
result = asyncio.get_event_loop().run_until_complete(
File "/usr/local/***/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File ".../sc2/main.py", line 483, in _host_game
await client.save_replay(save_replay_as)
File ".../sc2/client.py", line 117, in save_replay
result = await self._execute(save_replay=sc_pb.RequestSaveReplay())
File ".../sc2/protocol.py", line 77, in _execute
raise ProtocolError(f"{response.error}")
sc2.protocol.ProtocolError: ['Not in a game']
The game ended correctly, yet there is still an error trace, which does not belong there.
Minimal bot example provided by SoupCatcher
with trace:
The game ended correctly, yet there is still an error trace, which does not belong there.