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

Build Order Update #179

Open
y4n9squared opened this issue Oct 25, 2014 · 3 comments
Open

Build Order Update #179

y4n9squared opened this issue Oct 25, 2014 · 3 comments

Comments

@y4n9squared
Copy link

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?

@StoicLoofah
Copy link

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?

@y4n9squared
Copy link
Author

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.

@StoicLoofah
Copy link

That's a fair point. There are a few reasons why it's separate:

  1. spawningtool is built on top of rather than in conjunction with sc2reader. As such, it uses structures and conversions that don't necessarily align with the structure in sc2reader
  2. the functionality of spawningtool is sprawling for whatever I need for the spawningtool website. As such, it doesn't really neatly fit into the core library as an isolated plugin
  3. furthermore, my development is haphazard and irregular and best not linked to the typical open source flow for the sc2reader library

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

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