Open y4n9squared opened 9 years ago
This might be slight hijacking, but the purpose of Spawning Tool https://github.com/StoicLoofah/spawningtool is to extract build orders from replays, so it's a wrapper around sc2reader to do that. There's various normalization that goes into it that presumably could be handled within a plugin but doesn't quite cleanly map to the data from sc2reader in all cases just to make it readable, so it comes out slightly differently. Is this what you were hoping to accomplish, or was there something else you were looking for?
Thanks for the link @StoicLoofah. Indeed we are trying to accomplish the same goal, albeit the module that I'm using is substantially less featured but serves my purposes:
# -*- coding: utf-8 -*-
"""Build order plugin for sc2reader.
.. moduleauthor:: Yang Yang <y4n9squared@gmail.com>
"""
from sc2reader.events.game import AbilityEvent
_BUILD_IDS = {
3872: "Command Center",
3873: "Supply Depot",
# Rest omitted for brevity
}
class BuildOrderTracker(object):
"""Builds ``player.build_order`` lists where elements are tuples (frame,
second, building).
"""
name = 'BuildOrderTracker'
def handleInitGame(self, event, replay):
print(replay.players)
for human in replay.humans:
human.build_order = []
def handlePlayerActionEvent(self, event, replay):
if isinstance(event, AbilityEvent) and event.ability_id in _BUILD_IDS:
replay.humans[event.pid].build_order.append(
(event.frame, event.second, _BUILD_IDS[event.ability_id]))
def handlePlayerLeaveEvent(self, event, replay):
pass
def handleEndGame(self, event, replay):
pass
I do think, however, that the BO feature would enjoy more attention and support if it were merged into this repo.
That's a fair point. There are a few reasons why it's separate:
Regardless, you're welcome to steal mercilessly from the spawningtool work (or make your own, better version as you proposed above) if you want to write a plugin for the sc2reader core. I can see the value for it, and there could be a cleaned up version of spawningtool that would fit quite nicely into sc2reader. For myself, however, spawningtool serves my purposes and is made available as it aligns with others' goals
I noticed that past attempts to extract build orders (e.g. #35) have proved difficult. It seems pretty straight-forward now, correct? I've been using a custom engine plugin to parse build orders but have only tested it on a small handful of replays. Would you be interested in having me submit a pull request for the engine plugin?