Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant process the replays generated by python-sc2 #199

Open
histmeisah opened this issue Jan 18, 2024 · 2 comments
Open

Cant process the replays generated by python-sc2 #199

histmeisah opened this issue Jan 18, 2024 · 2 comments

Comments

@histmeisah
Copy link

histmeisah commented Jan 18, 2024

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

code is here:

import sc2reader
replay = sc2reader.load_replay('Altitude LE_20230903_161615_PROTOSS_VS_BUILD_IN_AI_MediumHard_Zerg_process_-5_checked.SC2Replay')

print(replay.players)

here is my error:

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

here is replay file:
replays.zip

@histmeisah
Copy link
Author

IndexError issues: https://github.com/ggtracker/sc2reader/issues?q=is%3Aissue+is%3Aopen+indexerror

All four issues point to the same line of code.

Thank you sir, but it is hard to find how to solve this problem,is this problem still existence?

@StoicLoofah
Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants