Spaces
Continuous
Bases: Space
create(shape, minimum, maximum, dtype=jnp.float32)
classmethod
Create a continuous space with a given shape, minimum and maximum values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape |
Shape
|
The shape of the space. |
required |
minimum |
Array
|
The minimum value of the space. |
required |
maximum |
Array
|
The maximum value of the space. |
required |
dtype |
dtype
|
The data type of the space. |
float32
|
Returns:
Name | Type | Description |
---|---|---|
Continuous |
Continuous
|
A continuous space with the given shape, minimum and maximum values. |
sample(key)
Generate a random sample from the space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Array
|
A random key to generate the sample. |
required |
Returns:
Name | Type | Description |
---|---|---|
Array |
Array
|
A random sample from the space. |
Discrete
Bases: Space
n: Array
property
The number of elements in the space.
Returns:
Name | Type | Description |
---|---|---|
Array |
Array
|
The number of elements in the space. |
create(n_elements, shape=(), dtype=jnp.int32)
classmethod
Create a discrete space with a given number of elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_elements |
int | Array
|
The number of elements in the space. |
required |
shape |
Shape
|
The shape of the space. |
()
|
dtype |
dtype
|
The data type of the space. |
int32
|
Returns:
Name | Type | Description |
---|---|---|
Discrete |
Discrete
|
A discrete space with the given number of elements. |
sample(key)
Generate a random sample from the space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Array
|
A random key to generate the sample. |
required |
Returns:
Name | Type | Description |
---|---|---|
Array |
Array
|
A random sample from the space. |
Space
Bases: PyTreeNode
Base class for all spaces in the game. Spaces define the shape and type of the observations, actions and rewards in the game.
The sample
method is used to generate random samples from the space.
Note
To initialize a space, use the create
method of the specific space class.
TODO
- maximum and minimum should be static objects, not arrays.
But how do we handle the case when they are not scalars? Maybe numpy arrays?
sample(key)
Generate a random sample from the space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Array
|
A random key to generate the sample. |
required |
Returns:
Name | Type | Description |
---|---|---|
Array |
Array
|
A random sample from the space. |