Comments (4)
Hmm, first thing is, you should be calling env.render('rgb_array')
(which will return a numpy array), not env.render('human')
, and this should be done within the wrapper's observation
method.
For speed, the simplest thing to do would be to render a smaller version of the grid. But the most efficient way would be to encode the grid directly as a numpy array with 3 values per cell as I did for partial observability. See the encode
method of the Grid
class: https://github.com/maximecb/gym-minigrid/blob/master/gym_minigrid/minigrid.py#L508
The only downside of this is that it doesn't currently encode the agent position.
from minigrid.
Thank you for the quick reply. Something like this should the trick then:
def observation(self, obs):
full_grid = self.env.grid.encode()
full_grid[self.env.agent_pos[0]][self.env.agent_pos[1]] = self.env.agent_dir
return full_grid
from minigrid.
Yes, like that, except you'd want to also encode that the agent is at that position, not just the agent direction. Something like:
full_grid[x, y, 0] = 255
full_grid[x, y, 1] = self.env.agent_dir
full_grid[x, y, 2] = 0
You would also want to change the observation_space
to have the correct shape.
from minigrid.
For anyone using this: I recommend encoding the agent as a much lower number that is closer to how the other objects are encoded.
While training on the Unlock-environment converged in ~12 minutes with the regular, egocentric view, training with the FullyObsWrapper never converged. At first I thought the egocentric view gives a translation invariance that the FullyObsWrapper doesn't have, so I tried to compensate and make the environment much simpler by removing colors, giving a small reward when picking up the key or reducing the action space such that pickup and toggle were reduced to 'interact' and drop was removed. Despite all of this, the model just wouldn't learn to go to the door after picking up the key.
Finally I changed the agent encoding from 255 to 9, and now training with the fully observable view converges as fast as with the egocentric view. Possibly the high value is too dominant in the convnet's processing.
PS. The current FullyObsWrapper also doesn't encode which item is being carried. In the egocentric view, this is encoded by showing the item as if it is at the agent's position, but the FullyObsWrapper overwrites this grid position to encode the agent. If color is not important, you can encode the carried object's type at the agent's position in the 3rd layer. If color is important, you will need to add a 4th layer to also include the carried object's color.
from minigrid.
Related Issues (20)
- [Question] Use of 'direction' in observation space? HOT 1
- [Bug Report] Toggling the box will make it disappear HOT 2
- [Bug Report] Error when creating BabyAI environment HOT 2
- [Question] Field of view algorithm explanation
- [Question] What do you mean by "done" action in the action space? HOT 3
- [Bug Report] Spec.to_json() of SimpleCrossing fails
- [Question] Getting total number of unique states HOT 1
- [Question] How to create vectorized envs for minigrid HOT 3
- [Bug Report] Unlock Pickup env is actually just Unlock HOT 4
- [Question] Difference between Minigrid and BabyAI envs HOT 1
- [Question] Is `ActionBonus` wrapper correct ? HOT 1
- [Question] How to build custom environment with custom action space HOT 1
- Python 3.11 support is missing from the README
- [Proposal] Update documentation HOT 3
- [Proposal] Add relevant project
- [Proposal] Discrete observations
- [Bug Report] ViewSizeWrapper ignored with RGBImgPartialObsWrapper HOT 1
- [Question] Get demonstration for 'MiniGrid-MultiRoom-N4-S5-v0' HOT 1
- [Bug Report] Cannot decode obs['image'] because of no implementation of agent in minigrid/core/world_object.py
- Accessing Specific Mission in BabyAI HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minigrid.