facebookresearch / BenchMARL

A collection of MARL benchmarks based on TorchRL
https://benchmarl.readthedocs.io/
MIT License
263 stars 38 forks source link

using a gym environment in benchmarl #115

Closed sAz-G closed 2 months ago

sAz-G commented 3 months ago

Hi everyone,

I am new to benchmarl and would like to create/integrate my own environment in order to train it in benchmarl.

I followed this tutorial on how to create a new task, but I do not exactly understand how to integrate my own environment.

Is it necessary to add the environment to torchrl like you did here?

Can I just import my gym environment and use its constructor as in this line? Or do I have to modify my environment to be able to use it in Benchmarl?

matteobettini commented 3 months ago

Hey!

thanks for asking this, I will work in adding more examples of this.

In multiagent settings the interface for gym environments is the one from PettingZoo

it is really easy to add your custom pettingzoo environment in benchmarl and you can see an example of how to do that in #84 (i ll add this example to the main repo examples)

in general, yes, you need a torchrl env in that line. But fortunately torchrl already has a wrapper for all petting zoo envs as shown above so you do not need to create a new one if you intend to use pettingzoo