TorchCraft / StarData

Starcraft AI Research Dataset
Other
567 stars 75 forks source link

How to extract unit information? #6

Closed andrewsilva9 closed 6 years ago

andrewsilva9 commented 6 years ago

Hello,

For each match in StarData, I need to extract the game state information. Specifically, the attributes of all of the units on the map. However, the recent decision to make StarCraft free has made installation of the correct versions (BW, BWAPI, TorchCraft, etc) on Ubuntu 16 (via Wine) very complicated. Is there an easy way to extract unit information from the .rep files or the .tcr files without needing StarCraft (given that I don't need to watch the replays)?

ebetica commented 6 years ago

Yes, if you follow the instructions to install StarData here, you should not need to install TorchCraft in WINE. TorchCraft is a server-client architecture, but you only need the client side to read .tcr replays. You can install the client in any environment you like.

Besides the undocumented dependency of torch7, simple follow:

https://github.com/TorchCraft/StarData#installing-torchcraft

andrewsilva9 commented 6 years ago

Thanks! Is there an example file for reading replays with Python? The linked python example is a C++ binding but I haven't been able to find a .py that makes use of the binding. Also, is there an example usage of extract_units ? It seems the argument list is too long if I run it over the StarData original_replays folder, and just cherry picking one or two out isn't printing anything meaningful out when it runs.

ebetica commented 6 years ago

There isn't really, sorry, I recommend just popping into ipython and playing with it, the list of available functions is here:

https://github.com/TorchCraft/TorchCraft/blob/90e3b9b12ece9fb7c5cbcc0e08a1e525a48a160d/py/pyreplayer.cpp

Small snippet (maybe some things are wrong from the top of my head):

from torchcraft import replayer

rep = replayer.load("path/to/replay.tcr")
for i in range(len(rep)):
  frame = rep.getFrame(i)
  print("On frame " + str(i))
  for u in frame.units:
    print(u.id, u.x, u.y)
andrewsilva9 commented 6 years ago

Great, thanks!