Farama-Foundation / Minigrid

Simple and easily configurable grid world environments for reinforcement learning
https://minigrid.farama.org/
Other
2.09k stars 604 forks source link

[Bug Report] Nothing shows up when rendering environments? #338

Closed amirest123 closed 1 year ago

amirest123 commented 1 year ago

Hi everyone, sorry if this has been covered or deemed too basic but I'm really having an issue here.

When I try to render an environment exactly as it's done in the example code here I simply get a blank window. I'm using windows 11 and currently running python 3.10.10 through a VS code jupyter notebook. I have minigrid 2.2.0, gymnasium 0.26.3, and pygame 2.3.0. However I've tried meddling with different versions of all these things and no configuration seems to work for me, even using the older version of minigrid that runs with matplotlib instead of pygame just produces a blank plot. I am able to get the expected window when running manual_control.py but nothing when trying to use minigrid as intended outside of that. I'm also able to render base gym environments with pygame, eg the lunar landing environment. I'd very much appreciate any help anyone could give me, thanks.

pseudo-rnd-thoughts commented 1 year ago

Thanks for the issue, I will have a look into it

BolunDai0216 commented 1 year ago

Can you try the following code

import gymnasium as gym

env = gym.make("MiniGrid-Empty-5x5-v0", render_mode="human", screen_size=640)
observation, info = env.reset(seed=42)
for _ in range(1000):
    action = env.action_space.sample()  # User-defined policy function
    observation, reward, terminated, truncated, info = env.step(action)

    if terminated or truncated:
        observation, info = env.reset()
env.close()

and see if you see anything?

amirest123 commented 1 year ago

@BolunDai0216 I had been using that exact code but without the screen_size parameter... I guess that makes all the difference because it's working as expected now. Thanks so much!

BolunDai0216 commented 1 year ago

The issue is we have set a really small screen_size as default, so it does appear, just not very noticeable.

You can try removing the screen_size parameter, and if you pay attention there should be a really small window somewhere on your screen.

Thanks for pointing this issue out, we'll update the default screen size.