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

Issue with color palette is breaking rendering #43

Open
JRod-Seed opened this issue Mar 19, 2024 · 0 comments
Open

Issue with color palette is breaking rendering #43

JRod-Seed opened this issue Mar 19, 2024 · 0 comments

Comments

@JRod-Seed
Copy link

Hi,
I just installed SMAC_V2 and am experimenting with the sample code provided in the Readme. Generally, everything is working well but I see that...

If you uncomment

env.render()

an error is thrown:

Traceback (most recent call last):
  File "/Users/justinrodriguez/git/explainable_starcraft/test_driver.py", line 87, in <module>
    main()
  File "/Users/justinrodriguez/git/explainable_starcraft/test_driver.py", line 64, in main
    env.render()  # Uncomment for rendering
    ^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/smacv2/env/starcraft2/wrapper.py", line 82, in render
    return self.env.render(mode=mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/smacv2/env/starcraft2/starcraft2.py", line 2285, in render
    from smacv2.env.starcraft2.render import StarCraft2Renderer
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/smacv2/env/starcraft2/render.py", line 15, in <module>
    from pysc2.lib.renderer_human import _Surface
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/pysc2/lib/renderer_human.py", line 35, in <module>
    from pysc2.lib import features
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/pysc2/lib/features.py", line 350, in <module>
    SCREEN_FEATURES = ScreenFeatures(
                      ^^^^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/pysc2/lib/features.py", line 323, in __new__
    palette=palette(scale) if callable(palette) else palette,
            ^^^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/pysc2/lib/colors.py", line 213, in unit_type
    return categorical(static_data.UNIT_TYPES, scale)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/site-packages/pysc2/lib/colors.py", line 224, in categorical
    palette = shuffled_hue(palette_size)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/justinrodriguez/git/explainable_starcraft/.venv/lib/python3.12/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
INFO:absl:Shutdown gracefully.
INFO:absl:Shutdown with return code: -15

This stems from the lambda function embedded here:

def shuffled_hue(scale):
  palette = list(smooth_hue_palette(scale))
  random.shuffle(palette, lambda: 0.5)  # Return a fixed shuffle
  return numpy.array(palette)

If you remove the lambda function in random.shuffle(), the problem goes away and the game is able to render.

FWIW I'm running in python 3.12.2

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

1 participant