Giter VIP home page Giter VIP logo

Comments (9)

maximecb avatar maximecb commented on July 24, 2024

Hi, yes there is. You can call the env.get_obs_render() method to generate images: https://github.com/maximecb/gym-minigrid/blob/master/gym_minigrid/minigrid.py#L1215

Note that this will produce a partial observation still, not a fully observable render. If you want a fully observable render, you can call env.render('rgb_array').

from minigrid.

MarcoMeter avatar MarcoMeter commented on July 24, 2024

How do you actually use env.get_obs_render()?

I tried it like this, but got a keyword argument exception on 'mode':

import gym_minigrid
import gym
import numpy as np
import matplotlib.pyplot as plt


env = gym.make("MiniGrid-FourRooms-v0")
obs = env.reset()
env.render()

agent_frame = env.get_obs_render(obs["image"], mode="rgb_array")

plt.imshow(agent_frame)
plt.show()

from minigrid.

MarcoMeter avatar MarcoMeter commented on July 24, 2024

I solved the issue by installing gym_minigrid from source. I installed the pip package previously.
@maximecb could you update the pip package?

from minigrid.

JeniaJitsev avatar JeniaJitsev commented on July 24, 2024

Related to that - is there an easy built-in way to mask out those parts of the environment that the agent cannot see from the current position (e.g due to walls, etc)?

EDIT: I see there are built-in methods to mask out cells that are invisible to the agent (https://github.com/maximecb/gym-minigrid/blob/master/gym_minigrid/minigrid.py#L1160). That is then translated to an image of environment via decode here https://github.com/maximecb/gym-minigrid/blob/master/gym_minigrid/minigrid.py#L548 .

It seems that an empty or invisible cell have the same representation (I suppose just black). Am I correct with that? If yes, for the agent an empty and invisible cell do not make a difference. I think though semantically, "visible and empty" cell (known to be empty) should deliver a different perception as "non-visible" cell (uncertain whether empty or whatever). For instance, invisible cells could be rendered as "grayed out", "foggy" etc. What do you folks think?

from minigrid.

maximecb avatar maximecb commented on July 24, 2024

Hi @JeniaJitsev, the masking should be enabled by default. You are correct that the agent gets a different perception for empty and invisible cells, but right now there is no special rendering for invisible cells in the RGB render.

from minigrid.

maximecb avatar maximecb commented on July 24, 2024

@MarcoMeter Thanks for the heads up. I just pushed a package version 0.0.5 to pip

from minigrid.

JeniaJitsev avatar JeniaJitsev commented on July 24, 2024

Hey @maximecb, thanks for quick response and package update. We can have a look whether there is a straighforward simple way to incorporate an option for rendering of empty vs invisible cells to be different in image observation, so it can be then enabled / disabled given corresponding demand.

from minigrid.

maximecb avatar maximecb commented on July 24, 2024

@JeniaJitsev can you open a new issue for this and explain what your use case is. That is, why you want them rendered differently/

from minigrid.

JeniaJitsev avatar JeniaJitsev commented on July 24, 2024

Sure, will do

from minigrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.