Visual Fields
- sorrel.observation.visual_field.visual_field(world: Gridworld, entity_map: dict[str, ndarray], vision: int | None = None, location: tuple | None = None, fill_entity_kind: str = 'Wall') ndarray
Visualize the world.
See
OneHotObservationSpec.observe()for an example of how this function is used.- Parameters:
world – The world tovisualize.
entity_map – The mapping between objects and visual appearance.
vision – The agent’s visual field radius. If None, the entire environment. Defaults to None.
location – The location to center the visual field on. If None, the entire environment. Defaults to None.
fill_entity_kind – if the agent’s vision is out of bounds, fill the space with appearances of this entity. Defaults to “Wall”.
- Returns:
An array with dtype float64 of shape (number of channels, 2 * vision + 1, 2 * vision + 1). Or if vision or location is None: (number of channels, world.width, world.layers). Here, the number channels is determined based on the one-hot entity map provided.
- sorrel.observation.visual_field.visual_field_ascii(world: Gridworld, entity_map: dict[str, str], vision: int | None = None, location: tuple | None = None, fill_entity_kind: str = 'Wall') ndarray
Visualize the world with ascii appearances.
If the world has multiple layers, and there are multiple non-empty entities on different layers at the same horizontal coordinate, only the top (i.e. highest layer) non-empty entity at that coordinate will be visualized.
See
AsciiObservationSpec.observe()for an example of how this function is used.- Parameters:
world – The world tovisualize.
entity_map – The mapping
appearance (between objects and visual)
character. (where the visual appearance must be a)
vision – The agent’s visual field radius. If None, the entire environment. Defaults to None.
location – The location to center the visual field on. If None, the entire environment. Defaults to None.
fill_entity_kind – if the agent’s vision is out of bounds, fill the space with appearances of this entity. Defaults to “Wall”.
- Returns:
An array of strings of shape (2 * vision + 1, 2 * vision + 1). Or if vision or location is None: (world.height, world.width).