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

Update unity_pettingzoo_base_env.py #6136

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

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.

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.

2 participants