Skip to content

Commit 7906de6

Browse files
committed
README/documentation updates.
1 parent 39c7a40 commit 7906de6

File tree

2 files changed

+166
-114
lines changed

2 files changed

+166
-114
lines changed

README.rst

Lines changed: 93 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,27 @@
11
What is sc2reader?
22
====================
33

4-
sc2reader is a python library for extracting information from various different
5-
Starcraft II resources. These resources currently include Replays, Maps, and
6-
Game Summaries; we may eventually include BNet profiles and possibly adapters
7-
to the more entrenched SCII sites like sc2ranks.
4+
sc2reader is a python library for extracting information from various different Starcraft II resources. These resources currently include Replays, Maps, and Game Summaries; we have plans to add support for Battle.net profiles and would gladly accept adapters to the more entrenched SCII sites such as sc2ranks.
85

9-
Our goal is to give anyone and everyone the power to construct their own
10-
tools, do their own analysis, and hack on their own Starcraft II projects
11-
under the open MIT license. Currently powering:
6+
There is a pressing need in the SC2 community for better statistics, better analytics, better tools for organizing and searching replays. Better websites for sharing replays and hosting tournaments. These tools can't be created with out first being able to open up Starcraft II game files and analyze the data within. Our goal is to give anyone and everyone the power to construct their own tools, do their own analysis, and hack on their own Starcraft II projects under the open MIT license.
127

13-
* Websites: `ggtracker.com`_, `gamereplays.org`_
14-
* Tools: `The Core`_
15-
* Experiments: `Midi Conversion`_
16-
17-
Our secondary goal is to become a reference implementation for people looking
18-
to implement libraries in other languages. For replays, it implements the
19-
replay format as specified in Blizzard's `s2protocol`_ project.
208

21-
The following is a list of partial implementations in other languages:
9+
Who Uses sc2reader?
10+
======================
2211

23-
* C#: `sc2replay-csharp`_ (special thanks for v1.5 help)
24-
* C++: `sc2pp`_
25-
* Javascript: `comsat`_
26-
* PHP: `phpsc2replay`_
12+
sc2reader is currently powering:
2713

28-
Unfortunately sc2reader does not implement a battle.net scraper for profile
29-
information. If you need the information I know of two projects that can get
30-
you started:
31-
32-
* Ruby: `bnet_scraper`_ - Maintained by Agora Games
33-
* Python: `sc2profile`_ - Currently unmaintained, slightly dated.
14+
* Websites: `ggtracker.com`_, `gamereplays.org`_, `sc2companion.com`_
15+
* Tools: `The Core`_
16+
* Experiments: `Midi Conversion`_
3417

35-
If you'd like your tool, site, project, or implementation listed above, drop
36-
us a line on our `mailing list`_ or stop by our #sc2reader IRC channel and say hi!
18+
If you use sc2reader and you would like your tool, site, project, or implementation listed above, drop us a line on our `mailing list`_ or stop by our #sc2reader IRC channel and say hi!
3719

3820

3921
Current Status
4022
=================
4123

42-
sc2reader is currently capable of parsing varying levels of information out of
43-
the three primary resource types listed below. For a more detailed and exact
44-
description of the information that can be extracted please consult the
45-
`documentation`_ hosted on Read the Docs.
46-
47-
The library is production ready and reasonably stable. `travis-ci`_ provides a
48-
record of our `continuous testing`_ and `coveralls.io`_ provides a record of our `test coverage`_.
24+
sc2reader is production ready at release and under active development on github. It is currently capable of parsing varying levels of information out of the three primary resource types listed below. For a more detailed and exact description of the information that can be extracted please consult the `documentation`_ hosted on ReadTheDocs.
4925

5026

5127
Replays
@@ -90,22 +66,20 @@ in future releases.
9066
Maps
9167
-------
9268

93-
Maps are currently parsed in the most minimal way possible and are an area for
94-
big improvement in the future. Currently the Minimap.tga packaged with the map
95-
is made available along with Name, Author, Description for ONLY enUS localized
96-
SCII map files. More robust Map meta data extraction will likely be added in
97-
future releases.
69+
Maps can be parsed for the following information:
70+
71+
* Minimap and Icon images (tga format)
72+
* enUS localized Name, Author, Description, Website (if available)
73+
* Map Dimensions, Camera Bounds, Tileset
74+
* Player Slot data and Advanced Teams alliance/enemy data.
9875

99-
There's a lot more in here to be had for the adventurous.
76+
There is a lot more in here to be had for the adventurous.
10077

10178

10279
Game Summaries
10380
-----------------
10481

105-
Game Summary files are downloaded by the client in order to allow you to view
106-
the game summary from your match history. Prior to 2.0.8 they were the only
107-
way to get the information from the summary screen. Since the 2.0.8 release
108-
you have been able to compute this information yourself from the replay files.
82+
Game Summary files are downloaded by the client in order to allow you to view the game summary from your match history. Prior to 2.0.8 they were the only way to get the information from the summary screen. Since the 2.0.8 release you have been able to compute this information yourself from the replay files.
10983

11084
Thank you Prillan and `Team Liquid`_ for helping to decode this file.
11185

@@ -115,76 +89,92 @@ Thank you Prillan and `Team Liquid`_ for helping to decode this file.
11589
* URLs to map localization files and images
11690
* Player build orders up to 64 (real) actions
11791

118-
Parsing on these files is now production ready for those that can get them. See
119-
the `Team Liquid`_ thread for details on how to go about getting them.
92+
Parsing on these files is now production ready for those that can get them. See the `Team Liquid`_ thread for details on how to go about getting them.
12093

12194
Again, these files are generally unnecessary after the 2.0.8 release.
12295

12396

124-
125-
Example Usage
97+
Basic Usage
12698
=====================
12799

128-
To demonstrate how you might use sc2reader in practice I've included some short
129-
contrived scripts below. For more elaborate examples, checkout the docs and the
130-
`sc2reader.scripts`_ package on Github or in the source.
100+
For examples scripts, checkout the docs and the `sc2reader.scripts`_ package on Github or in the source.
101+
102+
Loading Replays
103+
-------------------
104+
For many users, the most basic commands will handle all of their needs::
105+
106+
import sc2reader
107+
replay = sc2reader.load_replay('MyReplay', load_map=true)
131108

109+
This will load all replay data and fix GameHeart games. In some cases, you don't need the full extent of the replay data. You can use the load level option to limit replay loading and improve load times::
132110

133-
Downloading Maps
134-
--------------------
111+
# Release version and game length info. Nothing else
112+
sc2reader.load_replay('MyReplay.SC2Replay', load_level=0)
135113

136-
Save all the minimaps for all the games you've ever played::
114+
# Also loads game details: map, speed, time played, etc
115+
sc2reader.load_replay('MyReplay.SC2Replay', load_level=1)
137116

138-
import sc2reader, os, sys
117+
# Also loads players and chat events:
118+
sc2reader.load_replay('MyReplay.SC2Replay', load_level=2)
139119

140-
if not os.path.exists('minimaps'):
141-
os.makedirs('minimaps')
120+
# Also loads tracker events:
121+
sc2reader.load_replay('MyReplay.SC2Replay', load_level=3)
142122

143-
# Only load details file (level 1) and fetch the map file from bnet
144-
for replay in sc2reader.load_replays(sys.argv[1:], load_map=True, load_level=1):
145-
minimap_path = os.path.join('minimaps', replay.map_name.replace(' ','_')+'.tga')
146-
if not os.path.exists(minimap_path):
147-
with open(minimap_path, 'w') as file_out:
148-
file_out.write(replay.map.minimap)
149-
print("Saved Map: {0} [{1}]".format(replay.map_name, replay.map_hash))
123+
# Also loads game events:
124+
sc2reader.load_replay('MyReplay.SC2Replay', load_level=4)
150125

126+
If you want to load a collection of replays, you can use the plural form. Loading resources in this way returns a replay generator::
151127

152-
Organizing Replays
153-
----------------------
128+
replays = sc2reader.load_replays('path/to/replay/directory')
154129

155-
Organizing your 1v1 replays by race played and matchup and sortable by length::
156130

157-
import sc2reader, os, shutil, sys
131+
Loading Maps
132+
----------------
158133

159-
sorted_base = 'sorted'
160-
path_to_replays = 'my/replays'
134+
If you have a replay and want the map file as well, sc2reader can download the corresponding map file and load it in one of two ways::
161135

162-
for replay in sc2reader.load_replays(sys.argv[1], load_level=2):
163-
if replay.real_type != '1v1':
164-
continue
136+
replay = sc2reader.load_replay('MyReplay.SC2Replay', load_map=true)
137+
replay.load_map()
165138

166-
try:
167-
me = replay.player.name('ShadesofGray')
168-
you = team[(me.team.number+1)%2].players[0]
139+
If you are looking to only handle maps you can use the map specific load methods::
169140

170-
matchup = "{0}v{1}".format(me.play_race[0], you.play_race[1])
141+
map = sc2reader.load_map('MyMap.SC2Map')
142+
map = sc2reader.load_maps('path/to/maps/directory')
171143

172-
sorted_path = os.path.join(sorted_base,me.play_race[0],matchup)
173-
if not os.path.exists(sorted_path):
174-
os.makedirs(sorted_path)
175144

176-
filename = "{0} - {1}".format(replay.game_length, replay.filename)
177-
src = os.join(path_to_replays,replay.filename)
178-
dst = os.join(sorted_path, filename)
179-
shutil.copyfile(src, dst)
145+
Using the Cache
146+
---------------------
147+
148+
If you are loading a lot of remote resources, you'll want to enable caching for sc2reader. Caching can be configured with the following environment variables:
149+
150+
* SC2READER_CACHE_DIR - Enables caching to file at the specified directory.
151+
* SC2READER_CACHE_MAX_SIZE - Enables memory caching of resources with a maximum number of entries; not based on memory imprint!
152+
153+
You can set these from inside your script with the following code **BEFORE** importing the sc2reader module::
154+
155+
os.environ['SC2READER_CACHE_DIR'] = "path/to/local/cache"
156+
os.environ['SC2READER_CACHE_MAX_SIZE'] = 100
157+
158+
# if you have imported sc2reader anywhere already this won't work
159+
import sc2reader
180160

181-
except KeyError as e:
182-
continue # A game I didn't play in!
161+
162+
Using Plugins
163+
------------------
164+
165+
There are a growing number of community generated plugins that you can take advantage of in your project. See the article on `Creating GameEngine Plugins`_ for details on creating your own. To use these plugins you need to customize the game engine::
166+
167+
from sc2reader.engine.plugins import SelectionTracker, APMTracker
168+
sc2reader.engine.register_plugin(SelectionTracker())
169+
sc2reader.engine.register_plugin(APMTracker())
170+
171+
The :class:`~sc2reader.engine.plugins.ContextLoader` and :class:`~sc2reader.engine.plugins.GameHeartNormalizer` plugins are registered by default.
183172

184173

185174
Installation
186175
================
187176

177+
sc2reader runs on any system with Python 2.6+, 3.2+, or PyPy installed.
188178

189179

190180
From PyPI (stable)
@@ -205,16 +195,17 @@ or with setuptools (specify a valid x.x.x)::
205195
cd sc2reader-x.x.x
206196
python setup.py install
207197

208-
Releases to PyPi can be very delayed, for the latest and greatest you are encouraged
209-
to install from Github master which is **usually** kept quite stable.
198+
Releases to PyPi can be very delayed, for the latest and greatest you are encouraged to install from Github master.
210199

211200

212201
From Github
213202
--------------------------
214203

215204
Github master is generally stable with development branches more unstable.
216205

217-
Install from the latest source on github with pip::
206+
We use `travis-ci`_ to provide a record of our `continuous testing`_ and `coveralls.io`_ provides a record of our `test coverage`_. Please verify that tests are passing before installing development versions.
207+
208+
Install from the latest source on Github with pip::
218209

219210
pip install -e git+git://github.com/GraylinKim/sc2reader#egg=sc2reader
220211

@@ -229,58 +220,43 @@ or with setuptools::
229220
For Contributors
230221
-------------------
231222

232-
Contributors should install from an active git repository using setuptools in
233-
`develop`_ mode. This will install links to the live code so that local edits
234-
are available to external modules automatically::
223+
Contributors should install from an active git repository using setuptools in `develop`_ mode. This will install links to the live code so that local edits are available to external modules automatically::
235224

236225
git clone https://github.com/GraylinKim/sc2reader.git
237226
cd sc2reader
238227
python setup.py develop
239228

240-
Please review the CONTRIBUTING.md file and get in touch with us before doing
241-
too much work. It'll make everyone happier in the long run.
242-
229+
Please review the `CONTRIBUTING.md`_ file and get in touch with us before doing too much work. It'll make everyone happier in the long run.
243230

244231
Testing
245232
-------------------
246233

247-
We use the built in ``unittest`` module for testing. If you are still on Python
248-
2.6 you will need to install ``unittest2`` because our test suite requires newer
249-
features than are included in the main distribution.
234+
We use the built in ``unittest`` module for testing. If you are still on Python 2.6 you will need to install ``unittest2`` because our test suite requires newer features than are included in the main distribution.
250235

251236
To run the tests just use::
252237

253-
python -m unittest discover test_replays
254-
python -m unittest discover test_s2gs
238+
python test_replays/test_all.py
239+
python test_s2gs/test_all.py
255240

256-
When repeatedly running tests it can be very helpful to make sure you've
257-
set a local cache directory to prevent long fetch times from battle.net::
241+
When repeatedly running tests it can be very helpful to make sure you've set a local cache directory to prevent long fetch times from battle.net::
258242

259243
export SC2READER_CACHE_DIR=local_cache
260244
# or
261-
SC2READER_CACHE_DIR=local_cache py.test
245+
SC2READER_CACHE_DIR=local_cache python test_replays/test_all.py
262246

263247
Good luck, have fun!
264248

265249

266250
Community
267251
==============
268252

269-
sc2reader has a small but growing community of people looking to make tools and
270-
websites with Starcraft II data. If that sounds like something you'd like to be
271-
a part of please join our underused `mailing list`_ and start a conversation
272-
or stop by #sc2reader on FreeNode and say 'Hi'. We have members from all over
273-
Europe, Australia, and the United States currently, so regardless of the time,
274-
you can probably find someone to talk to.
253+
sc2reader has a small but growing community of people looking to make tools and websites with Starcraft II data. If that sounds like something you'd like to be a part of please join our underused `mailing list`_ and start a conversation or stop by #sc2reader on FreeNode and say 'Hi'. We have members from all over Europe, Australia, and the United States currently, so regardless of the time, you can probably find someone to talk to.
275254

276255

277256
Issues and Support
278257
=====================
279258

280-
We have an `issue tracker`_ on Github that all bug reports and feature requests
281-
should be directed to. We have a `mailing list`_ with Google Groups that you can
282-
use to reach out for support. We are generally on FreeNode in the #sc2reader
283-
and can generally provide live support and address issues there as well.
259+
We have an `issue tracker`_ on Github that all bug reports and feature requests should be directed to. We have a `mailing list`_ with Google Groups that you can use to reach out for support. We are generally on FreeNode in the #sc2reader and can generally provide live support and address issues there as well.
284260

285261

286262
Acknowledgements
@@ -297,7 +273,7 @@ and kept this project going.
297273
* Thanks to `ggtracker.com`_ for sponsoring further development and providing
298274
the thousands of test files used while adding s2gs and HotS support.
299275
* Thanks to Blizzard for supporting development of 3rd party tools and releasing
300-
their `s2protocol`_ reference implementation.
276+
their `s2protocol`_ full reference implementation.
301277

302278

303279
.. _s2protocol: https://github.com/Blizzard/s2protocol
@@ -324,3 +300,6 @@ and kept this project going.
324300
.. _travis-ci: https://travis-ci.org/
325301
.. _coveralls.io: https://coveralls.io
326302
.. _test coverage: https://coveralls.io/r/GraylinKim/sc2reader
303+
.. _CONTRIBUTING.md: https://github.com/GraylinKim/sc2reader/blob/master/CONTRIBUTING.md
304+
.. _sc2companion.com: http://sc2companion.com
305+
.. _Creating GameEngine Plugins: http://sc2reader.readthedocs.org/en/latest/articles/creatingagameengineplugin.html

0 commit comments

Comments
 (0)