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

[Feature Request] Support for Integrating Custom PettingZoo Environments with TorchRL's PettingZooEnv #2461

Closed
1 task done
andreamiele opened this issue Oct 3, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@andreamiele
Copy link

Motivation

I’ve created a custom PettingZoo environment and I’m looking to integrate it with benchmarl, which is based on torchrl. Currently, the PettingZooEnv class is implemented in torchrl, but it's unclear what the process is for adding a new custom PettingZoo environment.

This feature request is motivated by the need for easier registration and compatibility of custom environments with benchmarl and torchrl. It could help streamline the process for users who develop their own PettingZoo environments.

Solution

I would like to see a clear and concise method to register new PettingZoo environments, either through documentation or a straightforward integration pathway in torchrl. Ideally, this would allow custom PettingZoo environments to be added with minimal effort, leveraging the existing PettingZooEnv structure in torchrl.

Alternatives

An alternative approach could be to manually modify the PettingZooEnv implementation, but this is less user-friendly and may require in-depth knowledge of both frameworks. A guide or tutorial for integrating custom environments would also be an alternative solution.

Additional context

The current setup works well for predefined PettingZoo environments, but adding custom ones could be more intuitive. Enhancing the framework to support easier registration would save time and effort for users extending it with their own environments.

Checklist

  • I have checked that there is no similar issue in the repo (required)
@andreamiele andreamiele added the enhancement New feature or request label Oct 3, 2024
@matteobettini
Copy link
Contributor

There is an example of adding a new pettingzoo env from scratch here facebookresearch/BenchMARL#84

@matteobettini
Copy link
Contributor

matteobettini commented Oct 10, 2024

Essentially the process is just:

  • create an environment that inherits from pettingzoo.ParallelEnv
  • then wrap it with
 PettingZooWrapper( MyPettingzooEnv( **config) )

@andreamiele
Copy link
Author

@matteobettini thanks for the link. The issue here is that i have a pettingzoo.AECEnv
would that work?
thanks!

@matteobettini
Copy link
Contributor

matteobettini commented Oct 10, 2024

Benchmarl is not comaptible with turn-based AECEnvs (facebookresearch/BenchMARL#76)
Unless you make it parallel

But the torchrl wrapper is

@andreamiele
Copy link
Author

Okay thanks for the information.
I missed this point, i just thought i could put parallel=False in the PettingZooEnv.

Would you have any recommendation for AECEnv then @matteobettini ? Because I cannot make it parallel (the turn-based factor is important there).
Thanks again

@matteobettini
Copy link
Contributor

You can put parallel=False in the PettingZooEnv. PettingZooWrapper wont even need you to set anything as it can already read it is not parallel.

You just can't use benchmarl as of now. You can use torchrl

@andreamiele
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants