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

[Question] Agent does not appear to show up in integer array representation of minigrid environment #301

Closed JustinS6626 closed 1 year ago

JustinS6626 commented 1 year ago

Question

I am doing an RL experiment with the minigrid environment, so I ran a short test program to do a sanity check on the environment, in which I did a print of the integer array representation of the environment observation. I posted a screenshot here which shows the observation array:

Screenshot from 2023-01-27 21-53-04

The file constants.py in the core folder shows that integer value for the agent within the encoded observation should be 10, but none of the tile tuples show that value in the first term. Is that supposed to be the case? It prevents the agent from getting exact information about its position within the environment.

rodrigodelazcano commented 1 year ago

Hi @DarthMalloc. The observations you are getting are correct. The grid representation is a partial observation of the agent's point of view (represented in light grey in this image https://github.com/Farama-Foundation/Minigrid/blob/master/figures/door-key-curriculum.gif). If you'd like to get a full representation of the grid you can wrap the environment with the SymbolicObsWrapper:

from minigrid.wrappers import SymbolicObsWrapper
env = SymbolicObsWrapper(gym.make('EnvID'))
pseudo-rnd-thoughts commented 1 year ago

There is also a FullObsWrapper that will give you the integer array representation of the whole grid

JustinS6626 commented 1 year ago

Thank you very much for getting back to me so soon! Your response helps me a great deal! There is one last thing I was wondering - I noticed that the for the MiniGridEnv object class, there is a boolean parameter agent_pov, which is set to False by default. If this parameter is set to True, does it make the integer value for the agent appear within the observation array?

pseudo-rnd-thoughts commented 1 year ago

No, I believe it gets the observation in terms of the agent's point of view rather than the whole grid https://github.com/Farama-Foundation/Minigrid/blob/da409c4fc6db880613c819ab097d22522e602196/minigrid/minigrid_env.py#L723