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

How to get started? #68

Open
SayfT opened this issue Mar 4, 2018 · 2 comments
Open

How to get started? #68

SayfT opened this issue Mar 4, 2018 · 2 comments

Comments

@SayfT
Copy link

SayfT commented Mar 4, 2018

This is quite frustrating! I have been scouring the internet for some sort of idea how to get started with this replay parser. I can get the "load programmatically" http://s2protocol.readthedocs.io/en/latest/tutorial.html#using-s2protocol-programmatically

`import mpyq

archive = mpyq.MPQArchive("C:/Users/Tim/Desktop/Replays/replay1.SC2Replay")
contents = archive.header['user_data_header']['content']

from s2protocol import versions
header = versions.latest().decode_replay_header(contents)`

I get the header object result but it seems it is just a bunch of game version, and bunch of not what I need beeswax.

What other parameters are there besides ['user_data_header'] and ['content']? What do I need to parse to get the game events? such as number of workers, or minerals mined or game time?

The documentation does no help it just says "Oh you would need to load the files programmatically", ok, then what? the example was useful to load the replay file but how do I read the bloody contents?

I am sorry, I am a complete python noob and would prefer to work in R for this but unfortunately the parser is written in python :(

@amartin916
Copy link
Contributor

You can take the same approach I took for sc2replaystats, I output the data to json and import it into PHP as that's my preferred language. Sadly I have not used it in python other than exporting the data so I cant really offer any help

@jrepp
Copy link
Contributor

jrepp commented Mar 5, 2018

@SayfT if you're working in R then dumping to JSON is probably your best bet,

Try running

python s2_cli.py --all --ndjson your-reply.SC2Replay > your-replay.ndjson

This will dump all of the contents of the file into a newline delimited JSON file that is suitable for streaming.

You can then use a package such as: https://cran.r-project.org/web/packages/ndjson/ndjson.pdf to load your results into R.

There is some limited documentation available for the protocol itself and we welcome more (via PRs).

One of the strengths of R is it's capability in exploring new data sets. I'm excited to see what you can discover in your studies.

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

3 participants