Closed saleml closed 2 years ago
I updated the setup and yaml files to use the new released version of gym (0.25). This new gym release also contains a Text
spaces. There is no need for the StringGymSpace
I had written anymore.
Note: With gym 0.25, the step
function outputs a 5-tuple instead of a 4-tuple. gym raises a warning as minigrid still outputs a 4-tuple. I have not made the change to any step
function.
This looks very impressive, sorry for not responding faster. We are planning on code review and merging your PR, after we have fixed the CI. Would you be interested in working on gym and minigrid more? If so, could you join the gym discord https://discord.gg/nHg2JRN489 and contact me pseudornd
In recent updates of gym, the API has changed significantly, creating backward compatibility issues with minigrid and enviornments based on it.
In the gym.make function, the argument
disable_env_checker
is by default set toFalse
. This means that whenever an environment inheriting fromMiniGridEnv
is created usinggym.make('env')
, it is wrapped inPassiveEnvChecker
which verifies at each time step that the observations are contained in the observation space of the environment.I thus wrote a simplegym.Space
to handle textual observations, and changed the environment observation space accordingly.gym.spaces.Text
allows for textual observations.When using gym_minigrid's wrappers,
PassiveEnvChecker
failed, because some wrappers did not only define a new observation space of their own, but changed the unwrapped environment's observation space. This is about the wrappers that change theimage
part of the observation space, by overwritingself.observation_space.spaces["image"]
, which is not the right way to change this part of the observation space, given that it modifies that of the unwrapped environment as well, which is undesirable. This should be fixed now.The current version of gym
0.24.1
has a bug though, related toPassiveEnvChecker
, as described here and here; which will be fixed very shortly, as explained here. While it is obviously preferable to wait for the next version that introduces the right fixes, I slightly modifiedsetup.py
and.travis.yml
to use the branch associated to this PR, that will certainly be the basis of gym's next version. As soon as gym is updated, I'll update this PR !Rendering is handled differently in gym 0.24.1. A warning is raised whenever
self.render
is called withmode
argument. As you can see here: "The argument mode in render method is deprecated; use render_mode during environment initialization instead. See here for more information: https://www.gymlibrary.ml/content/api/". I made the corresponding change. Whenever rendering is expected,render_mode
should thus be given togym.make
.I made a small change to the metadata keys of
MiniGridEnv
match the metadata keys of gym (as in here)Seeding: The
seed
function is deprecated, and seeding is handled by thereset
method completely, rather than having to do bothenv.seed()
andenv.reset()
at each time. I made the corresponding change. gym's rng won't handlerandint
soon (as shown in some warnings), and I changed the_rand_int
,_rand_pos
, and_rand_bool
methods ofMiniGridEnv
accordingly.I added an argument to the method
get_view_exts
, given that one of the wrappers (ViewSizeWrapper
) that changes the agent view size used to modify the unwrapped environmentagent_view_size
attribute, thus breaking the compatibility between the unwrapped environment's observation_space and the new generated observations. This required adding an argument togen_obs_grid
. I also changedViewSizeWrapper
accordingly. I am not sure this is the simplest way to do it though.In
gym_minigrid/window.py
, Matplotlib raises a deprecation warning when setting the window title. This should be fixed now.I added a new wrapper:
DictObservationSpaceWrapper
. Put simply, this wrapper changes the mission from text to array. For this, I manually (I found no cleaner way; can you think of one?) listed all words used in the MiniGrid language and encoded each textual mission using the corresponding word indices. The mission has a maximum length (number of words). The benefit of doing this is that a numerical observation space for the mission part of the whole observation space is necessary to use RL libraries out of the box, that transform the observations (here = image + direction + mission as array) to tensors. I also added some corresponding tests inrun_tests.py
.- I movedEmptyEnvWithExtraObs
, that was defined inrun_tests.py
, toempty.py
in order to be able to register it correctly with gym (I couldn't figure out how to register it if it wa defined inrun_tests.py
). Registering environments seem to be essential with the changes to the gym API (in order to be able to userender_mode
argument when callinggym.make
for example)FourRoomsEnv
is now in lower-case letters, as in all other environments.There should be no warning when running
run_tests.py
ormanual_control.py
.