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

pathing_grid issue #11

Closed
Zymrael opened this issue Jun 1, 2019 · 4 comments
Closed

pathing_grid issue #11

Zymrael opened this issue Jun 1, 2019 · 4 comments

Comments

@Zymrael
Copy link
Contributor

Zymrael commented Jun 1, 2019

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: Dentosal/python-sc2#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
Copy link
Collaborator

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
Copy link
Contributor Author

Zymrael commented Jun 2, 2019

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

@leehoon7
Copy link

leehoon7 commented Jun 18, 2019

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
Copy link
Collaborator

Fixed in 260b2fb.

Any version of SC2 should work now @leeKanghoon

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

3 participants