gym_gridverse.representations package#
Submodules#
gym_gridverse.representations.observation_representations module#
- class ArrayObservationRepresentation(observation_space)[source]#
Bases:
ArrayRepresentation
[Observation
]
- class GridObjectObservationRepresentation(observation_space)[source]#
Bases:
ArrayRepresentation
[GridObject
]
- make_observation_representation(name, observation_space)[source]#
Factory function for observation representations
- Parameters
name (str) – name of the representation
observation_space (ObservationSpace) – inner-environment observation space
- Return type
- class DictObservationRepresentation(observation_space, representations)[source]#
Bases:
ObservationRepresentation
- property space: Dict[str, gym_gridverse.representations.spaces.Space]#
returns representation space as as dictionary of numpy arrays
- class GridObservationRepresentation(observation_space, grid_object_representation)[source]#
Bases:
ArrayObservationRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class ItemObservationRepresentation(observation_space, grid_object_representation)[source]#
Bases:
ArrayObservationRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class AgentIDGridObservationRepresentation(observation_space)[source]#
Bases:
ArrayObservationRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class DefaultGridObjectObservationRepresentation(observation_space)[source]#
Bases:
GridObjectObservationRepresentation
The default representation for a grid-object
Simply returns the grid-object indices. See
gym_gridverse.representations.representation.default_grid_object_representation_space()
andgym_gridverse.representations.representation.default_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class NoOverlapGridObjectObservationRepresentation(observation_space)[source]#
Bases:
GridObjectObservationRepresentation
The no-overlap representation for a grid-object
Guarantees that each channel uses separate indices. See
gym_gridverse.representations.representation.no_overlap_grid_object_representation_space()
andgym_gridverse.representations.representation.no_overlap_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class CompactGridObjectObservationRepresentation(observation_space)[source]#
Bases:
GridObjectObservationRepresentation
The compact representation for a grid-object
Guarantees that each channel uses separate indices, and removes empty gaps between indices. See
gym_gridverse.representations.representation.compact_grid_object_representation_space()
andgym_gridverse.representations.representation.compact_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
gym_gridverse.representations.representation module#
- class StateRepresentation(state_space)[source]#
Bases:
object
Converts a
State
into a dictionary ofndarray
.- abstract property space: Dict[str, gym_gridverse.representations.spaces.Space]#
returns representation space as as dictionary of numpy arrays
- class ObservationRepresentation(observation_space)[source]#
Bases:
object
Converts a
Observation
into a dictionary ofndarray
.- abstract property space: Dict[str, gym_gridverse.representations.spaces.Space]#
returns representation space as as dictionary of numpy arrays
- class ArrayRepresentation[source]#
Bases:
Generic
[T
]- abstract property space: gym_gridverse.representations.spaces.Space#
- Return type
- default_grid_object_representation_space(grid_object_types, grid_object_colors)[source]#
The default space of the representation
Returns a
Space
representing the space of a grid-object represented using type-index, status-index, and color-index.NOTE: used by
DefaultGridObjectStateRepresentation
andDefaultGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
- default_grid_object_representation_convert(grid_object)[source]#
The default conversion of a grid-object
Converts a grid-object into a 3-channel array of:
object type index
object state index
object color index
NOTE: used by
DefaultGridObjectStateRepresentation
andDefaultObservationGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
- no_overlap_grid_object_representation_space(grid_object_types, grid_object_colors)[source]#
The no-overlap space of the representation
Returns a
Space
representing the space of a grid-object represented using type-index, status-index, and color-index. Guarantees no overlap across channels, meaning that each channel uses separate indices.NOTE: used by
NoOverlapGridObjectStateRepresentation
andNoOverlapGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
- no_overlap_grid_object_representation_convert(grid_object_types, grid_object_colors, grid_object)[source]#
The no-overlap conversion of a grid-object
Converts a
GridObject
into a 3-channel array of type-index, status-index, and color-index. Guarantees no overlap across channels, meaning that each channel uses separate indices.NOTE: used by
NoOverlapGridObjectStateRepresentation
andNoOverlapGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
- compact_grid_object_representation_space(grid_object_type_map, grid_object_state_map, grid_object_color_map)[source]#
The compact space of the representation
Returns a
Space
representing the space of a grid-object represented using type-index, status-index, and color-index. Guarantees a compact no overlap representation across channels, meaning that each channel uses separate indices, and there are no gaps between the used indices.NOTE: used by
CompactGridObjectStateRepresentation
andCompactGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
- compact_grid_object_representation_convert(grid_object_type_map, grid_object_state_map, grid_object_color_map, grid_object)[source]#
The no-overlap conversion of a grid-object
Converts a
GridObject
into a 3-channel array of type-index, status-index, and color-index. Guarantees a compact no overlap representation across channels, meaning that each channel uses separate indices, and there are no gaps between the used indices.NOTE: used by
CompactGridObjectStateRepresentation
andCompactGridObjectObservationRepresentation
, refactored here because of DRY.- Return type
gym_gridverse.representations.spaces module#
- class SpaceType(value)[source]#
Bases:
Enum
An enumeration.
- CATEGORICAL = 0#
- DISCRETE = 1#
- CONTINUOUS = 2#
- is_dtype_integer(x)[source]#
checks if array has an integer type
- Parameters
x (numpy.ndarray) – x
- Return type
- is_dtype_floating(x)[source]#
checks if array has a floating type
- Parameters
x (numpy.ndarray) – x
- Return type
- is_dtype_compatible(x, space_type)[source]#
checks if array type is compatible with space type
- Parameters
x (numpy.ndarray) – x
space_type (SpaceType) – space_type
- Return type
- class Space(space_type, lower_bound, upper_bound)[source]#
Bases:
object
initializes a bounded space
lower_bound and upper_bound must have the same shape, and a dtype compatible with the space_type. Each element of lower_bound must be lower or equal to the corresponding element of upper_bound.
- Parameters
space_type (SpaceType) – space_type
lower_bound (numpy.ndarray) – lower_bound
upper_bound (numpy.ndarray) – upper_bound
- __init__(space_type, lower_bound, upper_bound)[source]#
initializes a bounded space
lower_bound and upper_bound must have the same shape, and a dtype compatible with the space_type. Each element of lower_bound must be lower or equal to the corresponding element of upper_bound.
- Parameters
space_type (SpaceType) – space_type
lower_bound (numpy.ndarray) – lower_bound
upper_bound (numpy.ndarray) – upper_bound
- contains(x)[source]#
checks if array is of the correct shape and type, and within the space bounds
- Parameters
x (numpy.ndarray) – x
- Return type
- static make_categorical_space(upper_bound)[source]#
initializes a bounded categorical space
upper_bound must have an integer dtype. Each element of upper_bound must be non-negative.
- Parameters
upper_bound (numpy.ndarray) – upper_bound
- Return type
- static make_discrete_space(lower_bound, upper_bound)[source]#
initializes a bounded discrete space
lower_bound and upper_bound must have the same shape, and an integer dtype. Each element of lower_bound must be lower or equal to the corresponding element of upper_bound.
- Parameters
space_type (SpaceType) – space_type
lower_bound (numpy.ndarray) – lower_bound
upper_bound (numpy.ndarray) – upper_bound
- Return type
- static make_continuous_space(lower_bound, upper_bound)[source]#
initializes a bounded continuous space
lower_bound and upper_bound must have the same shape, and a floating dtype. Each element of lower_bound must be lower or equal to the corresponding element of upper_bound.
- Parameters
space_type (SpaceType) – space_type
lower_bound (numpy.ndarray) – lower_bound
upper_bound (numpy.ndarray) – upper_bound
- Return type
gym_gridverse.representations.state_representations module#
- class ArrayStateRepresentation(state_space)[source]#
Bases:
ArrayRepresentation
[State
]
- class GridObjectStateRepresentation(state_space)[source]#
Bases:
ArrayRepresentation
[GridObject
]
- make_state_representation(name, state_space)[source]#
Factory function for state representations
- Parameters
name (str) – name of the representation
state_space (StateSpace) – inner-environment state space
- Return type
- class DictStateRepresentation(state_space, representations)[source]#
Bases:
StateRepresentation
- property space: Dict[str, gym_gridverse.representations.spaces.Space]#
returns representation space as as dictionary of numpy arrays
- class GridStateRepresentation(state_space, grid_object_representation)[source]#
Bases:
ArrayStateRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class ItemStateRepresentation(state_space, grid_object_representation)[source]#
Bases:
ArrayStateRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class AgentIDGridStateRepresentation(state_space)[source]#
Bases:
ArrayStateRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class AgentStateRepresentation(state_space)[source]#
Bases:
ArrayStateRepresentation
- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class DefaultGridObjectStateRepresentation(state_space)[source]#
Bases:
GridObjectStateRepresentation
The default representation for a grid-object
Simply returns the grid-object indices. See
gym_gridverse.representations.representation.default_grid_object_representation_space()
andgym_gridverse.representations.representation.default_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class NoOverlapGridObjectStateRepresentation(state_space)[source]#
Bases:
GridObjectStateRepresentation
The no-overlap representation for a grid-object
Guarantees that each channel uses separate indices. See
gym_gridverse.representations.representation.no_overlap_grid_object_representation_space()
andgym_gridverse.representations.representation.no_overlap_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
- class CompactGridObjectStateRepresentation(state_space)[source]#
Bases:
GridObjectStateRepresentation
The compact representation for a grid-object
Guarantees that each channel uses separate indices, and removes empty gaps between indices. See
gym_gridverse.representations.representation.compact_grid_object_representation_space()
andgym_gridverse.representations.representation.compact_grid_object_convert()
for more information.- property space: gym_gridverse.representations.spaces.Space#
- Return type
Module contents#
All that is in between the high-level implementation and low level representation for users