2022-05-10 17:18:06 +02:00
|
|
|
"""This module implements various spaces.
|
|
|
|
|
|
|
|
Spaces describe mathematical sets and are used in Gym to specify valid actions and observations.
|
|
|
|
Every Gym environment must have the attributes ``action_space`` and ``observation_space``.
|
|
|
|
If, for instance, three possible actions (0,1,2) can be performed in your environment and observations
|
|
|
|
are vectors in the two-dimensional unit cube, the environment code may contain the following two lines::
|
|
|
|
|
|
|
|
self.action_space = spaces.Discrete(3)
|
|
|
|
self.observation_space = spaces.Box(0, 1, shape=(2,))
|
2022-12-02 17:01:42 +01:00
|
|
|
|
|
|
|
All spaces inherit from the :class:`Space` superclass.
|
2022-05-10 17:18:06 +02:00
|
|
|
"""
|
2022-09-08 10:10:07 +01:00
|
|
|
from gymnasium.spaces.box import Box
|
|
|
|
from gymnasium.spaces.dict import Dict
|
|
|
|
from gymnasium.spaces.discrete import Discrete
|
|
|
|
from gymnasium.spaces.graph import Graph, GraphInstance
|
|
|
|
from gymnasium.spaces.multi_binary import MultiBinary
|
|
|
|
from gymnasium.spaces.multi_discrete import MultiDiscrete
|
|
|
|
from gymnasium.spaces.sequence import Sequence
|
|
|
|
from gymnasium.spaces.space import Space
|
|
|
|
from gymnasium.spaces.text import Text
|
|
|
|
from gymnasium.spaces.tuple import Tuple
|
|
|
|
from gymnasium.spaces.utils import flatdim, flatten, flatten_space, unflatten
|
2019-03-24 19:29:43 +01:00
|
|
|
|
2021-07-29 02:26:34 +02:00
|
|
|
__all__ = [
|
2022-11-15 16:12:42 +00:00
|
|
|
# base space
|
2021-07-29 02:26:34 +02:00
|
|
|
"Space",
|
2022-11-15 16:12:42 +00:00
|
|
|
# fundamental spaces
|
2021-07-29 02:26:34 +02:00
|
|
|
"Box",
|
|
|
|
"Discrete",
|
2022-07-11 16:39:04 +01:00
|
|
|
"Text",
|
2021-07-29 02:26:34 +02:00
|
|
|
"MultiDiscrete",
|
|
|
|
"MultiBinary",
|
2022-11-15 16:12:42 +00:00
|
|
|
# composite spaces
|
|
|
|
"Graph",
|
|
|
|
"GraphInstance",
|
2021-07-29 02:26:34 +02:00
|
|
|
"Tuple",
|
2022-08-15 17:11:32 +02:00
|
|
|
"Sequence",
|
2021-07-29 02:26:34 +02:00
|
|
|
"Dict",
|
2022-11-15 16:12:42 +00:00
|
|
|
# util functions (there are more utility functions in vector/utils/spaces.py)
|
2021-07-29 02:26:34 +02:00
|
|
|
"flatdim",
|
|
|
|
"flatten_space",
|
|
|
|
"flatten",
|
|
|
|
"unflatten",
|
|
|
|
]
|