farmgym.v2.gymUnion.MultiUnion¶
- class farmgym.v2.gymUnion.MultiUnion(spaces, maxnonzero=inf)[source]¶
Bases:
SpaceA tuple (i.e., product) of simpler spaces
Example usage: self.observation_space = spaces.Tuple((spaces.Discrete(2), spaces.Discrete(3)))
- Attributes:
is_np_flattenableChecks whether this space can be flattened to a
spaces.Box.np_randomLazily seed the PRNG since this is expensive and only needed if sampling from this space.
shapeReturn the shape of the space as an immutable property.
Methods
contains(x)Return boolean specifying if x is a valid member of this space.
from_jsonable(sample_n)Convert a JSONable data type to a batch of samples from this space.
sample()Randomly sample an element of this space.
seed([seed])Seed the PRNG of this space and possibly the PRNGs of subspaces.
to_jsonable(sample_n)Convert a batch of samples from this space to a JSONable data type.
- from_jsonable(sample_n)[source]¶
Convert a JSONable data type to a batch of samples from this space.
- property is_np_flattenable¶
Checks whether this space can be flattened to a
spaces.Box.
- property np_random: Generator¶
Lazily seed the PRNG since this is expensive and only needed if sampling from this space.
- sample()[source]¶
Randomly sample an element of this space.
Can be uniform or non-uniform sampling based on boundedness of space.
- Args:
mask: A mask used for sampling, expected
dtype=np.int8and see sample implementation for expected shape.- Returns:
A sampled actions from the space
- property shape: Optional[Tuple[int, ...]]¶
Return the shape of the space as an immutable property.