Skip to content

Conversation

AmineAndam04
Copy link

@AmineAndam04 AmineAndam04 commented Aug 18, 2024

Proposed change(s)

in the the _update_action_spaces method of the UnityPettingzooBaseEnv class, you force the actions to be of int32 and in the [-1,1] range (see the code below). This constraint doesn't apply to all scenarios

act_spec.continuous_size > 0:
                    c_space = spaces.Box(
                        -1, 1, (act_spec.continuous_size,), dtype=np.int32
                    )

It makes more sense to use the same logic as in _update_observation_spaces.

obs_spaces = tuple(
                    spaces.Box(
                        low=-np.float32(np.inf),
                        high=np.float32(np.inf),
                        shape=spec.shape,
                        dtype=np.float32,
                    )

We can generalize to all scenarios by using:

if act_spec.continuous_size > 0:
                    c_space = spaces.Box(
                        -np.float32(np.inf), np.float32(np.inf), (act_spec.continuous_size,), dtype=np.float32
                    )

Types of change(s)

  • [x ] Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@CLAassistant
Copy link

CLAassistant commented Aug 18, 2024

CLA assistant check
All committers have signed the CLA.

@alexander-zap
Copy link

+1, ran into the same problem. This is especially problematic when only using the mlagents-envs package for environment interfacing, but using own training algorithms (e.g., StableBaselines3).

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

Successfully merging this pull request may close these issues.

3 participants