|
Hello everybody,
I've been working on a Python (the programming language) library for the past week to read .rep files. The project is aptly named pyreplib and is far from being complete. Nevertheless, I thought I'd post about the work I've done so far and get some input.
The library currently only reads the header information (map and players information, game engine, replay time, etc.) The game actions will be coming soon, of course. I intend to make the source code available via Google Code once I get unit tests (and clean up the trunk )
One feature I intend to implement is dumping a .rep file to the JSON, XML and YAML formats, 'cause those are way easier for developers to toy around with.
Here's a sample session with the Python interactive interpreter:
>>> import pyreplib
>>> rep = pyreplib.Replay('foo.rep')
>>> print rep.game_name chosen
>>> print rep.map_name | iCCup | Blue Storm 1.2
>>> print rep.map_width, rep.map_height 128 96
>>> print rep.date 2008-06-24 16:32:26
>>> for player in rep.players: ... print '%s:\t%s' % (player.name, player.race_name) ...
Excello.ChOseN: Zerg ToT)ClouD(: Protoss Kachiun: Terran Excello.DetO: Zerg ToT)iNfeRnaL(: Protoss
Let me know what you think! (Pretty interested in Taiche's feedback)
|
This sounds awesome. Would love to get that code and have my IRC bot announce games as they occur ("<IRCBot> X has just beat Y in Starcraft on Blue Storm"). Could have a plugin for ChaosLauncher that uploads the replays automatically.
As for actions, it would be really nice to get APM too!
|
Taiche
France1963 Posts
Wow nice ! I didn't think you'd do it so quickly. How did you handle the compression algorithm ?
|
chebychev: What bot do you use? There's a Python bot that I really like, supybot and it has a plugin system, so it would definitely be feasible.
Taiche: I just used the Python C API to call jca's unpack_section() and return the value as a nice Python string. From then on, it was a piece of cake to use the struct module from Python's standard library to unpack the data.
|
Taiche
France1963 Posts
Yeah, unpacking the whole stuff is the only big issue ; once you know what data does what, then it's easy. Good job, keep it going
|
I have a homegrown bot which has been my Python-learning platform the past few years It has a plugin architecture, though I'm sure it's not anywhere as advanced as supybot. Anyway, can't wait til your code is released. Let me know if I can help, test, whatever.
|
Zurich15358 Posts
Wow this is soo cool! Please let me know when there is code to play with!
|
Nice. Python is a really good language, would love to mess around with this.
|
I'm very happy to see that there's interest here. I have tomorrow off (Canada's Day, eh!) so I'll work on the project more and hopefully have something to show by the weekend.
|
thats the whole code? what the.
|
Raithed: that's not the whole code. That's a sample of how you'd use it. Of course, under the hood there's a lot more.
|
At first I thought this was literally a library for all python replays, but I was wrong.
Great work, btw.
|
thank you very much, i've been hoping for something like this myself.
i'll be sure and download it once it's released
|
5673 Posts
I'm moderately skilled in py and would love to help you write an IRC bot plugin if needed. I've done that sorta thing before, so let me know. Good work mate.
|
Oh sweet, I was wondering if something like this existed, it could be very helpful for certain types of analysis. I don't actually know Python yet though but that's another issue .
|
On July 01 2008 13:45 gravity wrote:Oh sweet, I was wondering if something like this existed, it could be very helpful for certain types of analysis. I don't actually know Python yet though but that's another issue  .
There are TONS of good resources for learning it online. The official web page is one place. If you already know programming, the free book "Diving Into Python" is pretty good. If you're new to programming "Thinking Like a Computer Scientist in Python" is good choice too (free also.)
Edit: links:
http://diveintopython.org/toc/index.html http://www.greenteapress.com/thinkpython/html/
|
Korea (South)11587 Posts
i'm kinda confused what will be different between this and BWChart?
|
py kinda resembles c or something alike, whats the different? more data, less junk?
|
On July 01 2008 04:21 gnuvince wrote: One feature I intend to implement is dumping a .rep file to the JSON, XML and YAML formats, 'cause those are way easier for developers to toy around with.
Awesome idea.
Although I must be the only person in the world who doesn't like python T_T
|
Ahh not sure if it's possible but is it possible to make a Starcraft screensaver that plays replays?
|
|
|
|
|
|