Farama-Foundation / SuperSuit

A collection of wrappers for Gymnasium and PettingZoo environments (being merged into gymnasium.wrappers and pettingzoo.wrappers
Other
441 stars 56 forks source link

Pettingzoo to Stable baselines3 #200

Closed KevinJeon closed 1 year ago

KevinJeon commented 1 year ago

Hi, I have a problem with testing the learning algorithm using stable-baselines3.

First, I made a custom env with pettingzoo and it passes the api_test and parallel_api_test.

But, when I wrapped it with ss.concat_vec_envs_v1,

the model(DQN) has an error with

AssertionError: The algorithm only supports (<class 'gym.spaces.discrete.Discrete'>,) as action spaces but Discrete(5) was provided

But in gymnasium is used in pettingzoo, how can I solve this issue?

p.s. when I use gym.spaces.Box, error occured in making env.

thanks

my code is following:

    parallel_env = parallel_wrapper_fn(ChaseEnv)(**dict(config=config.env))
    env = ss.pettingzoo_env_to_vec_env_v1(parallel_env)
    env = ss.concat_vec_envs_v1(env, 1, num_cpus=0, base_class='stable_baselines3')
    print(env)
    model = DQN("MlpPolicy", env, verbose=1)
KevinJeon commented 1 year ago

Oh I solved this problem by adding this code sys.modules["gym"] = gymnasium!