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

Error with Goal in view using RGBImgPartialObsWrapper #163

Closed dlevenstein closed 2 years ago

dlevenstein commented 2 years ago

I get the following error whenever there's a Goal in view, when using the RGBImgPartialObsWrapper

File "/Users/dl2820/Code Libraries/gym-minigrid/gym_minigrid/wrappers.py", line 210, in observation rgb_img_partial = env.get_obs_render(

File "/Users/dl2820/Code Libraries/gym-minigrid/gym_minigrid/minigrid.py", line 1290, in get_obs_render grid, vis_mask = Grid.decode(obs)

File "/Users/dl2820/Code Libraries/gym-minigrid/gym_minigrid/minigrid.py", line 618, in decode v = WorldObj.decode(type_idx, color_idx, state)

File "/Users/dl2820/Code Libraries/gym-minigrid/gym_minigrid/minigrid.py", line 145, in decode v = Goal(color)

TypeError: init() takes 1 positional argument but 2 were given

dlevenstein commented 2 years ago

Fixed by changing lines 164-165

from: class Goal(WorldObj): def init(self,): super().init('goal', 'green')

to: class Goal(WorldObj): def init(self, color='green'): super().init('goal', color)

Similar will probably need to be done for Lava, Home, Food, Water.

maximecb commented 2 years ago

This might be related to modifications you've made because a color argument is not passed to Goal in the decode method here: https://github.com/maximecb/gym-minigrid/blob/master/gym_minigrid/minigrid.py#L142

Which happens on line 142, not 145.

I could see a color to the Goal class, but not Lava

dlevenstein commented 2 years ago

Oh, this must be an edit in the fork I branched off of. My bad. thanks for the great tool! :)

maximecb commented 2 years ago

No problem, have fun :)