openai / procgen

Procgen Benchmark: Procedurally-Generated Game-Like Gym-Environments

Home Page:https://openai.com/blog/procgen-benchmark/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Environment resets to the exact same level

roger-creus opened this issue · comments

Hi!

I am new to ProcGen, and I'm seeing that using this very simple code I get that the map looks the same after 5 different environment resets. I would expect to see different randomly generated maps. Am I missing something?

import gym
import matplotlib.pyplot as plt

env = gym.make("procgen:procgen-maze-v0")

for i in range(5):
    obs = env.reset()
    plt.figure()
    plt.imshow(obs)
    plt.savefig(f"img_{i}.png")

Thank you!

Solved by using the PrcogenEnv class and not using any manual reset

import matplotlib.pyplot as plt
import procgen
import numpy as np
from procgen import ProcgenEnv, ProcgenGym3Env

env = ProcgenEnv(num_envs=1, env_name="maze", num_levels=0, start_level=0, distribution_mode="hard")

for i in range(3000):
    ns, r, d, inf = env.step(np.array([5]))
    if d:
        print("new episode")
        plt.figure()
        plt.imshow(ns["rgb"][0])
        plt.savefig(f"img_{i}.png")