Easy way to get the size of a map?

22 views
Skip to first unread message

Kevin Leung

unread,
Mar 25, 2014, 1:02:43 AM3/25/14
to sc2r...@googlegroups.com
So I'm currently trying to do some stuff approximating things on the map, and I see that a lot of events have x, y locations on them. I was wondering whether anyone knew an easy way to get the size of the map as a whole.

I see it can be done using the map info, doing something like:

replay = sc2reader.load_replay('...')
replay.load_map()
map_height = replay.map.map_info.height
map_width = replay.map.map_info.width

The catch appears to be that the second line has to load the map, and though presumably all of this is less of a big deal with caching, I would still prefer to be able to punch through a bunch of replays without that step. Does anyone know if the map dimensions are stored elsewhere or can be inferred from other data?

If anyone is interested, I'm planning on putting some location approximation into spawningtool so you can better label events in the game. For example, you could determine if a StarGate is in-base or is a proxy, or if a Banshee kill on a worker is harass or hunting down a scout.

Graylin Kim

unread,
Mar 25, 2014, 11:33:48 AM3/25/14
to sc2r...@googlegroups.com
I don't believe that there is anyway to get the playable map area without loading the map file. As you pointed out, you'll want to cache the maps to the file system to prevent your processing from taking forever.

If anyone is interested, I'm planning on putting some location approximation into spawningtool so you can better label events in the game. For example, you could determine if a StarGate is in-base or is a proxy, or if a Banshee kill on a worker is harass or hunting down a scout.

For this purpose, it might be significantly easier for you to do a distance to buildings check. If the building in question is closer to enemy buildings then it is likely a proxy. If the kill in question is closer to enemy buildings then it is probably harassment. I think you'd be able to find thresholds where that sort of analysis was pretty reliable.

~Graylin


--
You received this message because you are subscribed to the Google Groups "sc2reader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sc2reader+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Joerg

unread,
Mar 25, 2014, 12:19:44 PM3/25/14
to sc2reader
I'm not aware of any way to do it without loading the map file.  Of course, you can cache the map sizes themselves, so the map-loading penalty is paid only once per new map that you see.

You could approximate map size by using the min and max coordinates of all events in a replay, but that will be a bad approximation in many cases.

Kevin Leung

unread,
Mar 26, 2014, 2:22:28 AM3/26/14
to sc2r...@googlegroups.com
Thanks for the quick responses. I guess I'll just have to test it to see if the impact in production is noticeable with caching. I guess even for big tournament replay packs, they're using they're 7 map pool anyways, so it shouldn't hurt too bad.

That's a good idea about checking distance to buildings. My general thought here was that breaking the map up into general regions would be more natural and approachable, since it would also allow me to label a player as spawning at 12:00 or 5:00. I'll play around with the different approaches and see which are the most reliable.
Reply all
Reply to author
Forward
0 new messages