Closed yogyan6 closed 10 months ago
The error you're encountering is due to changes in the random.shuffle()
function in Python versions later than 3.9. Specifically, in Python 3.9 and earlier, random.shuffle()
allowed for an optional random function to determine the order of shuffling, which is not the case in Python 3.11 that you are using. I faced a similar issue with Python 3.11. An effective solution is to downgrade your Python version to 3.9. In my experience, Python 3.9.17 worked seamlessly.
solution: If there are too many error parameters, change the color.py in the pysc2 package
random.shuffle(palette, lambda: 0.5)
random.shuffle(palette)
I downloaded sc2 and pysc2, and I want to use pycharm to run the first code. The protobuf version is too high, and I changed to a lower version. the following is my code and error code: from pysc2.agents import base_agent from pysc2.env import sc2_env from pysc2.lib import actions, features, units from absl import app import random
class PyAgent(base_agent.BaseAgent): def step(self, obs): super(PyAgent, self).step(obs) return actions.FUNCTIONS.no_op()
def main (unused_argv): agent = PyAgent () try: while True: with sc2_env.SC2Env( map_name="Simple64", players=[sc2_env.Agent(sc2_env.Race.terran), sc2_env.Bot (sc2_env.Race.random, sc2_env.Difficulty.very_easy)], agent_interface_format=features.AgentInterfaceFormat( feature_dimensions=features.Dimensions(screen=84, minimap=64), use_feature_units=True), step_mul=8, game_steps_per_episode=0, visualize=True) as env: agent.setup(env.observation_spec(), env.action_spec())
if name == 'main': app.run(main)
errror: Traceback (most recent call last): File "C:\Users\Yogyan\PycharmProjects\pythonProject1\pysc.py", line 2, in
from pysc2.env import sc2_env
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\env\sc2_env.py", line 28, in
from pysc2.lib import features
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\lib\features.py", line 350, in
SCREEN_FEATURES = ScreenFeatures(
^^^^^^^^^^^^^^^
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\lib\features.py", line 323, in new
palette=palette(scale) if callable(palette) else palette,
^^^^^^^^^^^^^^
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\lib\colors.py", line 213, in unit_type
return categorical(static_data.UNIT_TYPES, scale)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\lib\colors.py", line 224, in categorical
palette = shuffled_hue(palette_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Yogyan\PycharmProjects\pythonProject1\Lib\site-packages\pysc2\lib\colors.py", line 121, in shuffled_hue
random.shuffle(palette, lambda: 0.5) # Return a fixed shuffle
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Random.shuffle() takes 2 positional arguments but 3 were given