pysc2-examples
pysc2-examples copied to clipboard
ValueError: You must specify the list of players.
When i run python train_mineral_shards.py --algorithm=a2c
it says: ValueError: You must specify the list of players.
does anyone know what happen?
i got the same problem, did u solve it? i would like to thank u a lot ,if u can help me.
@viponedream and @lml519
New pysc2 api requires list of players. For example:
players=[sc2_env.Agent(sc2_env.Race.terran)]
Note even a single player needs to be wrapped in a list. Hopefully this helps.
@lbianculli
thanks for your help. But I have a little question. I want to know where the player should add to? Directly add them after the command "python train_mineral_shards.py --algorithm=a2c" or see them as codes and add them into a file? If see them as code, which file can I add them in?
Thanks a lot. Your reply has hepled me alot. I am very appreciate, if u can give me hands again.
@lbianculli when i add them into : with sc2_env.SC2Env( map_name="DefeatZerglingsAndBanelings", step_mul=step_mul, visualize=True, players=[sc2_env.Agent(sc2_env.Race.terran)],
it comes a new error:Please specify agent_interface_format.
Hi @lml519 , I generally add them in the code, I dont think this repo allows for adding players via CLI. Below is some example code that I use as a boilerplate:
` self._env = sc2_env.SC2Env(players=[sc2_env.Agent(sc2_env.Race.terran)],
map_name=self.id,
visualize=self.render,
agent_interface_format=[features.parse_agent_interface_format(
feature_screen=self.spatial_dim,
feature_minimap=self.spatial_dim,
rgb_screen=None,
rgb_minimap=None
)],
step_mul=self.step_mul,)
`
As you can see, the agent_interface_format can be found in the pysc2.lib.features file. Last I checked, going to SC2Env's docstring tells you which args are/arent needed as well.
Hope this helps.
@lbianculli thanks a lot. I have checked the SC2Env and change the code in "subproc_vec_env.py"and"train_mineral_shards".Then,the output change into : raise _exceptions.UnparsedFlagAccessError(error_message) absl.flags._exceptions.UnparsedFlagAccessError: Trying to access flag --sc2_run_config before flags were parsed. absl.flags.exceptions.UnparsedFlagAccessError: Trying to access flag --sc2_run_config before flags were parsed. File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\run_configs_init.py", line 39, in get if FLAGS.sc2_run_config is None: # Find the highest priority as default. File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\absl\flags_flagvalues.py", line 491, in getattr raise _exceptions.UnparsedFlagAccessError(error_message) absl.flags._exceptions.UnparsedFlagAccessError: Trying to access flag --sc2_run_config before flags were parsed.
I think the main problem is that the different between pysc2-version2.0 and the version this using. It's very hard to change them into correct. Do u know how to solve this problem. Thank u very much.
@lbianculli I've tried all 4 players in SC2Env, and they all output the same results.Just like the output I showed above. Then I tried to add the player into 2,3 and 4. It display the errors just like the warning which has been written in the file. Such as "Single player maps require exactly one Agent." So I think the reason of this problem is caused by the changement has some conflicts between Pysc2-Version 2.0 and 1.0.
If you add this line
flags.FLAGS(sys.argv)
somewhere after the declaration of all command line flags (within the code itself), that should take care of the first error, e.g.
flags.DEFINE_string('example_str', 'example', 'Just some string.')
flags.FLAGS(sys.argv)
As for the second error. I'd imagine that is coming from adding players to the SC2Env constructor. Basically, that error is thrown because minigames only allow for one player, and you are specificying more than one, I am guessing?
Try fixing the first issue with the line above, and if errors still persist and you wouldnt mind sharing your code, we can go from there.
Thanks.
Thank u very much for ur sincerely help. I change the position of "flags.FLAGS(sys.argv)" to the end of the declaration of all command line flags. Then the game can run. Before the game run correctly, the terminal display "TypeError: Agent(race=[<Race.terran: 1>], name='
thank u.
If you wouldnt mind pasting into the prompt the code that's throwing the error, as well as the trace if you can, that would be great. Just use the "insert code" format option at the top of the text box, right next to the quotation marks.
@lbianculli Sorry for repling lately.I run it on my windows10 os.And the output is that:
pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html Process Process-3: Process Process-2: Traceback (most recent call last): File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 297, in _boots self.run() Traceback (most recent call last): File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 99, in run self._target(*self.args, **self.kwargs) File "C:\Users\lml96\Desktop\pysc2-examples\common\vec_env\subproc_vec_env.py", line 28, in worker step_mul=2) as env: File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 288, i it self._create_join() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 421, i ate_join join.race = random.choice(p.race) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 674, in setter field_setter(self, new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 662, in field_setter new_value = type_checker.CheckValue(new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\type_chec y", line 157, in CheckValue raise TypeError(message) TypeError: Agent(race=[<Race.terran: 1>], name='
') has type <class 'pysc2.env.sc2_env.Agent'>, but expect of: (<class 'int'>,) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 297, in _boots self.run() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 99, in run self._target(*self._args, **self._kwargs) Process Process-1: Process Process-4: Traceback (most recent call last): File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 297, in _boots self.run() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 99, in run self.target(*self.args, **self.kwargs) File "C:\Users\lml96\Desktop\pysc2-examples\common\vec_env\subproc_vec_env.py", line 28, in worker step_mul=2) as env: File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 288, i it self.create_join() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 421, i ate_join join.race = random.choice(p.race) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 674, in setter field_setter(self, new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 662, in field_setter new_value = type_checker.CheckValue(new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\type_chec y", line 157, in CheckValue raise TypeError(message) TypeError: Agent(race=[<Race.terran: 1>], name=' ') has type <class 'pysc2.env.sc2_env.Agent'>, but expect of: (<class 'int'>,) File "C:\Users\lml96\Desktop\pysc2-examples\common\vec_env\subproc_vec_env.py", line 28, in worker step_mul=2) as env: File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 288, i it self._create_join() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 421, i ate_join join.race = random.choice(p.race) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 674, in setter field_setter(self, new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 662, in field_setter new_value = type_checker.CheckValue(new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\type_chec y", line 157, in CheckValue raise TypeError(message) TypeError: Agent(race=[<Race.terran: 1>], name='') has type <class 'pysc2.env.sc2_env.Agent'>, but expect of: (<class 'int'>,) Traceback (most recent call last): File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 297, in _boots self.run() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 99, in run self._target(*self.args, **self.kwargs) File "C:\Users\lml96\Desktop\pysc2-examples\common\vec_env\subproc_vec_env.py", line 28, in worker step_mul=2) as env: File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 288, i it self._create_join() File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\pysc2\env\sc2_env.py", line 421, i ate_join join.race = random.choice(p.race) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 674, in setter field_setter(self, new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\python_me py", line 662, in field_setter new_value = type_checker.CheckValue(new_value) File "C:\Users\lml96\AppData\Local\Programs\Python\Python37\lib\site-packages\google\protobuf\internal\type_chec y", line 157, in CheckValue raise TypeError(message) TypeError: Agent(race=[<Race.terran: 1>], name=' ') has type <class 'pysc2.env.sc2_env.Agent'>, but expect of: (<class 'int'>,)
could you post some of your own code around where this error is being raised? Thanks.