pysc2 icon indicating copy to clipboard operation
pysc2 copied to clipboard

Agents fail on update

Open Ian-r-temple opened this issue 6 years ago • 5 comments

I recently noted that there had been a lot of changes since i last updated (I believe end of July) and decided to update via pip install --upgrade https://github.com/deepmind/pysc2/archive/master.zip

I now get the following errors when attempting to run "$ python -m pysc2.bin.agent --map Simple64" or $ python -m pysc2.bin.agent --map CollectMineralShards --agent pysc2.agents.scripted_agent.CollectMineralShards" as given in the readme

Traceback (most recent call last): File "C:\Python\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Python\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python\lib\site-packages\pysc2\bin\agent.py", line 164, in app.run(main) File "C:\Python\lib\site-packages\absl\app.py", line 300, in run _run_main(main, args) File "C:\Python\lib\site-packages\absl\app.py", line 251, in _run_main sys.exit(main(argv)) File "C:\Python\lib\site-packages\pysc2\bin\agent.py", line 150, in main run_thread(agent_classes, players, FLAGS.map, FLAGS.render) File "C:\Python\lib\site-packages\pysc2\bin\agent.py", line 108, in run_thread run_loop.run_loop(agents, env, FLAGS.max_agent_steps, FLAGS.max_episodes) File "C:\Python\lib\site-packages\pysc2\env\run_loop.py", line 48, in run_loop timesteps = env.step(actions) File "C:\Python\lib\site-packages\pysc2\env\available_actions_printer.py", line 32, in step all_obs = super(AvailableActionsPrinter, self).step(*args, **kwargs) File "C:\Python\lib\site-packages\pysc2\env\base_env_wrapper.py", line 42, in step return self._env.step(*args, **kwargs) File "C:\Python\lib\site-packages\pysc2\lib\stopwatch.py", line 212, in _stopwatch return func(*args, **kwargs) File "C:\Python\lib\site-packages\pysc2\env\sc2_env.py", line 548, in step return self._step(step_mul) File "C:\Python\lib\site-packages\pysc2\env\sc2_env.py", line 565, in _step return self._observe(target_game_loop=target_game_loop) File "C:\Python\lib\site-packages\pysc2\env\sc2_env.py", line 670, in _observe self._get_observations(target_game_loop) File "C:\Python\lib\site-packages\pysc2\env\sc2_env.py", line 638, in _get_observations for c, f in zip(self._controllers, self._features))) File "C:\Python\lib\site-packages\pysc2\lib\run_parallel.py", line 56, in run return [funcs0] File "C:\Python\lib\site-packages\pysc2\env\sc2_env.py", line 632, in parallel_observe agent_obs = f.transform_obs(obs) File "C:\Python\lib\site-packages\pysc2\lib\stopwatch.py", line 212, in _stopwatch return func(*args, **kwargs) File "C:\Python\lib\site-packages\pysc2\lib\features.py", line 1520, in transform_obs self.available_actions(obs.observation), dtype=np.int32) File "C:\Python\lib\site-packages\pysc2\lib\stopwatch.py", line 212, in _stopwatch return func(*args, **kwargs) File "C:\Python\lib\site-packages\pysc2\lib\features.py", line 1569, in available_actions raise ValueError("Failed to find applicable action for {}".format(a)) ValueError: Failed to find applicable action for ability_id: 1 requires_point: false

If someone could tell me what's going wrong here or how i can roll back to a version before this problem, that would be greatly appreciated (yes, i foolishly did not back-up before running this update) Edit: I found and backversioned to 2.0.2 through pip and everything is running again, but am obviously missing any changes since that release

Ian-r-temple avatar Sep 12 '19 21:09 Ian-r-temple

Hi @tewalds

This issue and question here is from September and still, there is no reply. pycs2 with the latest starcraft version is not working for me as well for a number of other people. It seems like testing was not on the very high level before the release.

But even if it was the case, I didn't know what could prevent replying to the question for almost half a year and fixing the issue reported by the community.

ViktorM avatar Feb 09 '20 08:02 ViktorM

I'm having the same issue when trying to run the prepare datasets function from this repo. Python 3.7, Windows 10, latest version 3.0.0 of PySC2, and version 5.0.9 of the game, trying to process version 4.7.1 replays. Would be cool to see this get updated/some insight into the error. Unless this repo is about to be archived or something...

windowshopr avatar Mar 29 '22 05:03 windowshopr

Narrowed it down to this section from /pysc2/lib/features.py

  @sw.decorate
  def available_actions(self, obs):
    """Return the list of available action ids."""
    available_actions = set()
    hide_specific_actions = self._agent_interface_format.hide_specific_actions
    for i, func in six.iteritems(actions.FUNCTIONS_AVAILABLE):
      if func.avail_fn(obs):
        available_actions.add(i)
    for a in obs.abilities:
      if a.ability_id not in actions.ABILITY_IDS:
        logging.warning("Unknown ability %s seen as available.", a.ability_id)
        continue
      found_applicable = False
      for func in actions.ABILITY_IDS[a.ability_id]:
        if func.function_type in actions.POINT_REQUIRED_FUNCS[a.requires_point]:
          if func.general_id == 0 or not hide_specific_actions:
            available_actions.add(func.id)
            found_applicable = True
          if func.general_id != 0:  # Always offer generic actions.
            for general_func in actions.ABILITY_IDS[func.general_id]:
              if general_func.function_type is func.function_type:
                # Only the right type. Don't want to expose the general action
                # to minimap if only the screen version is available.
                available_actions.add(general_func.id)
                found_applicable = True
                break
      if not found_applicable:
        raise ValueError("Failed to find applicable action for {}".format(a))
    return list(available_actions)

I'll try and do some print outs and debugging on my end to see if I can somehow clumsily figure this out for anyone new (like me) trying to get setup with SC2 RL

windowshopr avatar Mar 29 '22 05:03 windowshopr

Got same problem in pysc2 4.0.0. Any updates here ?

nicklhy avatar Aug 15 '22 09:08 nicklhy

I got same problem in pysc2 4.0.0. It's been almost 4 years, is there any solution?

Felixvillas avatar May 30 '23 08:05 Felixvillas