oxwhirl / smac

SMAC: The StarCraft Multi-Agent Challenge
MIT License
1.07k stars 226 forks source link

pathing_grid issue #11

Closed Zymrael closed 5 years ago

Zymrael commented 5 years ago

New version of SCII is causing problems to several APIs (smac included). The first problem caused by the update seems to be related to the pathing grid's shape (data values have been turned into bits).

bits_per_pixel: 1
size {
  x: 32
  y: 32
}
data: "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374?\377\377\374\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-bbe461e77b17> in <module>
      5 
      6 for e in range(n_episodes):
----> 7     env.reset()
      8     terminated = False
      9     episode_reward = 0

~\.conda\envs\rl\lib\site-packages\smac\env\starcraft2\starcraft2.py in reset(self)
    320         if self._episode_count == 0:
    321             # Launch StarCraft II
--> 322             self._launch()
    323         else:
    324             self._restart()

~\.conda\envs\rl\lib\site-packages\smac\env\starcraft2\starcraft2.py in _launch(self)
    311         self.pathing_grid = np.flip(
    312             np.transpose(np.array(list(map_info.pathing_grid.data))
--> 313                 .reshape(self.map_x, self.map_y)), 1) / 255
    314 
    315     def reset(self):

ValueError: cannot reshape array of size 128 into shape (32,32)

Other users are encountering similar problems when using python-sc2: https://github.com/Dentosal/python-sc2/issues/283

Things were working well until StarCraft2 version 4.8.4. In 4.8.5, the pixelmap changed and self.state.upgrades stopped working. Thus, self.already_pending_upgrade(UPGRADEID) stopped working if the upgrade was completely researched (should return 1, but returns 0 instead). self.state.upgrades was fixed in SC2 version 4.9.0.

The master branch of this library is working for SC2 version 4.8.4, while the develop branch fixed the issues with pixelmap introduced in 4.8.5 (and is the same in 4.8.6). Pixelmaps were starting in the top left but are now starting in the bottom left, so they were flipped in y-axis. Also pixelmap values changed from bytes to bits (like pathing grid, placement grid, and in 4.9.0 also creep map).

samvelyan commented 5 years ago

Hi @Zymrael ,

Thanks for pointing this out. I'm aware of the issue and will fix it as soon as possible.

In the meanwhile, you can use an older version of SC2 by passing corresponding version to SMAC, e.g., env = StarCraft2Env(map_name="3s5z", game_version="4.6.2").

To check which versions of SC2 you have installed, check the Versions directory in SC2 dir. For instance, I have Base60321 Base67926 Base69232 Base71663 Base74071 installed. You can use https://github.com/deepmind/pysc2/blob/master/pysc2/run_configs/lib.py to map these base numbers to StarCraft II versions.

Zymrael commented 5 years ago

Thanks for the swift reply and for the work done to maintain SMAC.

leehoon7 commented 5 years ago

Hi, I have a same problem and try to solve by changing the version.

I added parameter 'game_version' and set to '4.6.2'.

but, still have same error : "ValueError: cannot reshape array of size 128 into shape (32,32)"

And I checked SC2 version in my starcraft2 file, there was only the latest version '74456' which is 4.9.1 maybe.

Do I have to download old version? or changing the parameter is all?

Thank you!

samvelyan commented 5 years ago

Fixed in 260b2fbc188e9696bd0f411e76aa5f53bb986cc3.

Any version of SC2 should work now @LeeKanghoon