You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cant process the replays generated by python-sc2 #199
I have writed some botai to play starcraft2 by python-sc2,and i find sc2reader cant process these replays.
python version:3.10
sc2reader version:1.8.0
python-sc2 version: 6.5.0
Traceback (most recent call last):
File "E:\python_code\sc2data_process\process_replay\process_replay\test_sc2reader.py", line 2, in
replay = sc2reader.load_replay('Altitude LE_20230903_161615_PROTOSS_VS_BUILD_IN_AI_MediumHard_Zerg_process_-5_checked.SC2Replay')
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 88, in load_replay
return self.load(Replay, source, options, **new_options)
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 166, in load
return self._load(cls, resource, filename=filename, options=options)
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 175, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\resources.py", line 302, in init
self.load_all_details()
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\resources.py", line 444, in load_all_details
self.load_details()
File "E:\anaconda\envs\sc2env\lib\site-packages\sc2reader\resources.py", line 389, in load_details
self.region = details["cache_handles"][0].server.lower()
IndexError: list index out of range
Right, so I think the comment linking points to a general issue that the sc2reader library assumes that these replays were generated off of actually played games. Those games have things like server details and such that are pulled into the library. Since you said that python-sc2 to simulate the games, I suspect that some of these details aren't present.
A possible fix here is to see if you can bypass these lines if the cache handles aren't present. However, I'm not sure how many other places make the same assumption or if you will run into more problems down the line.
If you do get it working assuming that these details are optional, you're welcome to open a PR for it!
Activity
sc2musa commentedon Jan 18, 2024
Thank you sir, but it is hard to find how to solve this problem,is this problem still existence?
StoicLoofah commentedon Jan 22, 2024
Right, so I think the comment linking points to a general issue that the sc2reader library assumes that these replays were generated off of actually played games. Those games have things like server details and such that are pulled into the library. Since you said that python-sc2 to simulate the games, I suspect that some of these details aren't present.
A possible fix here is to see if you can bypass these lines if the cache handles aren't present. However, I'm not sure how many other places make the same assumption or if you will run into more problems down the line.
If you do get it working assuming that these details are optional, you're welcome to open a PR for it!