python-sc2: ValueError: 3794 is not a valid AbilityId

full stacktrace

$ python3 examples/protoss/cannon_rush.py
err = 3 /opt/blizzard/buildserver/data.noindex/repositories/sc2/branches/SC2.4.9/Game/Contrib/macteam/libs/ClampCursor/Contrib/mach_override/mach_override.c:244
err = 3 /opt/blizzard/buildserver/data.noindex/repositories/sc2/branches/SC2.4.9/Game/Contrib/macteam/libs/ClampCursor/Contrib/mach_override/mach_override.c:258
err = 3 /opt/blizzard/buildserver/data.noindex/repositories/sc2/branches/SC2.4.9/Game/Contrib/macteam/libs/ClampCursor/Contrib/mach_override/mach_override.c:263
INFO:sc2.protocol:Client status changed to Status.launched (was None)
INFO:sc2.controller:Creating new game
INFO:sc2.controller:Map:     (2)CatalystLE
INFO:sc2.controller:Players: Bot(Race.Protoss, <__main__.CannonRushBot object at 0x10b8d28d0>, name='CheeseCannon'), Computer(Race.Protoss, Difficulty.Medium)
INFO:sc2.protocol:Client status changed to Status.init_game (was Status.launched)
INFO:sc2.protocol:Client status changed to Status.in_game (was None)
INFO:root:Player id: 1 (CheeseCannon)
INFO:sc2.sc2process:kill_switch: Process cleanup
INFO:sc2.sc2process:Cleaning up...
INFO:sc2.sc2process:Cleanup complete
Traceback (most recent call last):
  File "examples/protoss/cannon_rush.py", line 60, in <module>
    main()
  File "examples/protoss/cannon_rush.py", line 57, in main
    ], realtime=False)
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/main.py", line 306, in run_game
    _host_game(map_settings, players, **kwargs)
  File "/Users/wseobseo/anaconda3/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
    return future.result()
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/main.py", line 233, in _host_game
    result = await _play_game(players[0], client, realtime, portconfig, step_time_limit, game_time_limit, rgb_render_config)
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/main.py", line 204, in _play_game
    result = await _play_game_ai(client, player_id, player.ai, realtime, step_time_limit, game_time_limit)
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/main.py", line 91, in _play_game_ai
    game_data = await client.get_game_data()
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/client.py", line 143, in get_game_data
    return GameData(result.data)
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/game_data.py", line 29, in __init__
    self.abilities = {a.ability_id: AbilityData(self, a) for a in data.abilities if a.ability_id in ids}
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/game_data.py", line 29, in <dictcomp>
    self.abilities = {a.ability_id: AbilityData(self, a) for a in data.abilities if a.ability_id in ids}
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/game_data.py", line 93, in __init__
    assert self.id != 0
  File "/Users/wseobseo/.local/lib/python3.7/site-packages/sc2/game_data.py", line 101, in id
    return AbilityId(self._proto.remaps_to_ability_id)
  File "/Users/wseobseo/anaconda3/lib/python3.7/enum.py", line 307, in __call__
    return cls.__new__(cls, value)
  File "/Users/wseobseo/anaconda3/lib/python3.7/enum.py", line 555, in __new__
    return cls._missing_(value)
  File "/Users/wseobseo/anaconda3/lib/python3.7/enum.py", line 568, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 3794 is not a valid AbilityId
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10c14b860>

my library versions

$ pip freeze | grep 'sc\?2'
s2clientprotocol==4.9.0.74071.0
sc2==0.11.1

Also, I use a touch bar MacBook Pro.

Could anybody help me ? thank you very much!

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 11
  • Comments: 25

Commits related to this issue

Most upvoted comments

It is a total mess right now.

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).

Dentosal needs a working version for his competition https://artificial-overmind.reaktor.com which runs on (I believe) 4.7.1 because it is using this linux client https://github.com/Blizzard/s2client-proto#linux-packages and the master branch works fine for that.

However in SC2 client 4.9.0 a new bug got introduced (that was already there about half a year ago in november 2018) that you can’t run 2 bots against each other, but running bot against built-in AI works (because only one SC2 client needs to run for this). So new competitions like Probots ( https://www.eschamp.com/probots-2019-2/ ) decided to also run on client version 4.8.4

TLDR: If you want to run the latest SC2 client version 4.9.0 on windows/mac: You need to download and install the develop branch (instruction here: https://github.com/Dentosal/python-sc2/issues/266 ) and go into the library installation in your python folder and do the following changes: In sc2/game_state.py you have to change self.creep: PixelMap = PixelMap(self.observation_raw.map_state.creep, mirrored=True) to self.creep: PixelMap = PixelMap(self.observation_raw.map_state.creep, in_bits=True, mirrored=True) and in sc2/game_data.py you have to remove the line assert self.id != 0.

Also you need to download generate_id_constants_from_stableid.py from here https://github.com/Dentosal/python-sc2 and let it run once (create subfolders sc2/ids first) to update the IDs that were changed once again in 4.9.0 Then copy these newly generated files into the sc2/ids/ folders of the library in your python installation.

  1. Browse to c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\sc2 (I’m using Python in Visual Studio 2019 environment)
  2. Edit game_data.py and comment out ‘assert self.id != 0’ with # in front, save changes.
  3. Edit pixel_map.py and comment out ‘assert self.bits_per_pixel % 8 == 0, “Unsupported pixel density”’ with # in front, save changes.

Run again and game should work now fully updated on 4 Jul 2019

Rather than everyone applying their own fix / workaround, I hope a patch is released with this problem fixed… (minor version upgrade or something)

 if key in abilities and v["index"] == 0:
    print(key)
    # raise ValueError

Then the value is error is gone and it only affects UNLOADUNIT

You can comment out : “assert self.id != 0” in game_data.py, then the game should run again.

You should also now be able to install from a specific fork, see https://github.com/Dentosal/python-sc2/issues/298#issuecomment-513579799

The install command on windows is

pip install pipenv
pip install --upgrade  git+https://github.com/Dentosal/python-sc2@develop
  1. Browse to c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\sc2 (I’m using Python in Visual Studio 2019 environment)
  2. Edit game_data.py and comment out ‘assert self.id != 0’ with # in front, save changes.
  3. Edit pixel_map.py and comment out ‘assert self.bits_per_pixel % 8 == 0, “Unsupported pixel density”’ with # in front, save changes.

Run again and game should work now fully updated on 4 Jul 2019

I have commented both assert self.id != 0 and 'assert self.bits_per_pixel % 8 == 0 and it worked! Thank you!

Applied fixed in this thread for same issue, now it’s throwing a “AssertionError: Unsupported pixel density”

EDIT: I found the fix for this error. Delete that line of code! (that assert line in pixel_map.py)

Strange that it differs for different users, but happy you got it to work 🙂

On Sun, Jul 21, 2019 at 4:00 PM Batman notifications@github.com wrote:

Ok. I got it to work and this is what I did. I am using Python 3.7 and using SC2 4.9.3

  1. I force upgraded via this post. #266 https://github.com/Dentosal/python-sc2/issues/266
  2. The post by BurnySc2 fixed my problem.

GLHF GG

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Dentosal/python-sc2/issues/283?email_source=notifications&email_token=AMQYRNMUCNI5GHQAYZXC2DDQARTWHA5CNFSM4HPWAO7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2OEECQ#issuecomment-513557002, or mute the thread https://github.com/notifications/unsubscribe-auth/AMQYRNKSBPR43D7ZIDXT6YLQARTWHANCNFSM4HPWAO7A .

Thank you Batman

On Sun, 21 Jul 2019, 3:40 AM Batman notifications@github.com wrote:

  1. Browse to c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\sc2 (I’m using Python in Visual Studio 2019 environment)
  2. Edit game_data.py and comment out ‘assert self.id != 0’ with # in front, save changes.
  3. Edit pixel_map.py and comment out ‘assert self.bits_per_pixel % 8 == 0, “Unsupported pixel density”’ with # in front, save changes.

Run again and game should work now fully updated on 4 Jul 2019

There is no game_data.py to edit but the rest of pysc2 is there

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Dentosal/python-sc2/issues/283?email_source=notifications&email_token=AMQYRNMB6X2EKWUQWDWRHYLQAO5CBA5CNFSM4HPWAO7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2NZDUQ#issuecomment-513511890, or mute the thread https://github.com/notifications/unsubscribe-auth/AMQYRNOYBV4RHRTBO7YLAP3QAO5CBANCNFSM4HPWAO7A .

  1. Browse to c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\sc2 (I’m using Python in Visual Studio 2019 environment)
  2. Edit game_data.py and comment out ‘assert self.id != 0’ with # in front, save changes.
  3. Edit pixel_map.py and comment out ‘assert self.bits_per_pixel % 8 == 0, “Unsupported pixel density”’ with # in front, save changes.

Run again and game should work now fully updated on 4 Jul 2019

There is no game_data.py to edit but the rest of pysc2 is there