farmgym.v2.gymUnion.MultiUnion

class farmgym.v2.gymUnion.MultiUnion(spaces, maxnonzero=inf)[source]

Bases: Space

A tuple (i.e., product) of simpler spaces

Example usage: self.observation_space = spaces.Tuple((spaces.Discrete(2), spaces.Discrete(3)))

Attributes:
is_np_flattenable

Checks whether this space can be flattened to a spaces.Box.

np_random

Lazily seed the PRNG since this is expensive and only needed if sampling from this space.

shape

Return 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.

contains(x)[source]

Return boolean specifying if x is a valid member of this space.

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.int8 and see sample implementation for expected shape.

Returns:

A sampled actions from the space

seed(seed=None)[source]

Seed the PRNG of this space and possibly the PRNGs of subspaces.

property shape: Optional[Tuple[int, ...]]

Return the shape of the space as an immutable property.

to_jsonable(sample_n)[source]

Convert a batch of samples from this space to a JSONable data type.