ggtracker / sc2reader

Extracts gameplay information from Starcraft II replay files
http://pypi.python.org/pypi/sc2reader
MIT License
145 stars 144 forks source link

Can I get more detailed timestamps? #150

Closed bw-leran closed 3 years ago

bw-leran commented 3 years ago

I'm using ContextLoader, APMTracker, and SelectionTracker to get timestamped player actions, however the timestamps only go to 2 decimals (for example 06.38), is there a way to get more precise timestamps? (for example 06.3845)

dsjoerg commented 3 years ago

If memory serves there's only 16 frames per "second", so the two decimals provided ought to uniquely identify the exact time, and you could do postprocessing on your end to add in the desired decimals once you know how long your "second" is. To put it another way, if you look at the distribution of just the decimal part, I think you'll see that only certain values appear — and from that, knowing that they are in fact evenly spaced, you can infer what the rest of the decimals should be.

On Fri, Aug 13, 2021 at 10:09 PM bw-leran @.***> wrote:

I'm using ContextLoader, APMTracker, and SelectionTracker to get timestamped player actions, however the timestamps only go to 2 decimals (for example 06.38), is there a way to get more precise timestamps? (for example 06.3845)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ggtracker/sc2reader/issues/150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF7HKNT3S5RU2ULTVENZWDT4XF3ZANCNFSM5CESS2AQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

bw-leran commented 3 years ago

Thanks for the detailed response. It appears that the 06.38 actually translates to 06 minutes 38 seconds (I should have been more specific in my original post).

StoicLoofah commented 3 years ago

@bw-leran I'm a bit hesitant on this change since timestamps currently correspond to what is shown to players, and this would be a breaking change.

Given @dsjoerg comment, though, I believe that most events throughout sc2reader are given a frame as well. Is that available on the data you're looking at, and if so, can you calculate the timestamps yourself?

bw-leran commented 3 years ago

@StoicLoofah I see. I haven't seen any events labelled with frames. Perhaps I am not producing the events correctly to get the frames?

Here is how I'm producing the events...

replay = sc2reader.load_replay(
    replay_file,
    engine=sc2reader.engine.GameEngine(plugins=[ContextLoader(), APMTracker(), SelectionTracker()]))
for event in replay.events:
    print(event)

Output is...

05.52   LiquidClem      GetControlGroupEvent
05.52   LiquidClem      CameraEvent at (89.1796875, 65.63671875)
05.52   Enki            CameraEvent at (113.234375, 150.65234375)
05.52   Enki            CameraEvent at (113.5546875, 150.49609375)

I'm only seeing things labelled by time. If I were able to get the frame of each event then I should be able to calculate them myself.

StoicLoofah commented 3 years ago

I think you should be able to get it via event.frame. It's defined on the GameEvent class, which determines most things

https://github.com/ggtracker/sc2reader/blob/44e0f33a052caa816c3b0e09975a17433c773d7a/sc2reader/events/game.py#L29

What you outputted just looks like the __str__ version of the object as defined here, which derives the seconds fromt he frame https://github.com/ggtracker/sc2reader/blob/44e0f33a052caa816c3b0e09975a17433c773d7a/sc2reader/events/game.py#L40-L54

bw-leran commented 3 years ago

Perfect, this is very helpful. I should be able to calculate the time from here. Thank you!