lit_sb3.envs.multi_input_envs
source module lit_sb3.envs.multi_input_envs
Classes
-
SimpleMultiObsEnv — Base class for GridWorld-based MultiObs Environments 4x4 grid world.
source class SimpleMultiObsEnv(num_col: int = 4, num_row: int = 4, random_start: bool = True, discrete_actions: bool = True, channel_last: bool = True)
Bases : gym.Env
Base class for GridWorld-based MultiObs Environments 4x4 grid world.
____________
| 0 1 2 3|
| 4|¯5¯¯6¯| 7|
| 8|_9_10_|11|
|12 13 14 15|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯
start is 0 states 5, 6, 9, and 10 are blocked goal is 15 actions are = [left, down, right, up]
simple linear state env of 15 states but encoded with a vector and an image observation
each column is represented by a random vector and each row is represented by a random image, both sampled once at creation time.
Parameters
-
num_col : int — Number of columns in the grid
-
num_row : int — Number of rows in the grid
-
random_start : bool — If true, agent starts in random position
-
channel_last : bool — If true, the image will be channel last, else it will be channel first
Attributes
-
unwrapped : Env[ObsType, ActType] — Returns the base non-wrapped environment.
-
np_random_seed : int — attr:
_np_random_seedthat if not set will first initialise with a random int as seed. -
np_random : np.random.Generator — attr:
_np_randomthat if not set will initialise with a random seed.
Methods
-
init_state_mapping — Initializes the state_mapping array which holds the observation values for each state.
-
get_state_mapping — Uses the state to get the observation mapping.
-
init_possible_transitions — Initializes the transitions of the environment.
-
step — Run one timestep of the environment's dynamics. When end of.
-
render — Prints the log of the environment.
-
reset — Resets the environment state and step count and returns reset observation.
source method SimpleMultiObsEnv.init_state_mapping(num_col: int, num_row: int) → None
Initializes the state_mapping array which holds the observation values for each state.
Parameters
-
num_col : int — Number of columns.
-
num_row : int — Number of rows.
source method SimpleMultiObsEnv.get_state_mapping() → dict[str, np.ndarray]
Uses the state to get the observation mapping.
Returns
-
observation dict {'vec' — ..., 'img': ...}
source method SimpleMultiObsEnv.init_possible_transitions() → None
Initializes the transitions of the environment.
The environment exploits the cardinal directions of the grid by noting that they correspond to simple addition and subtraction from the cell id within the grid.
- up => means moving up a row => means subtracting the length of a column
- down => means moving down a row => means adding the length of a column
- left => means moving left by one => means subtracting 1
- right => means moving right by one => means adding 1
Thus one only needs to specify in which states each action is possible in order to define the transitions of the environment
source method SimpleMultiObsEnv.step(action: int | np.ndarray) → GymStepReturn
Run one timestep of the environment's dynamics. When end of.
episode is reached, you are responsible for calling reset()
to reset this environment's state.
Accepts an action and returns a tuple (observation, reward, terminated, truncated, info).
Parameters
-
action : int | np.ndarray
-
action : int | np.ndarray — The action to execute in the environment.
Returns
-
GymStepReturn — tuple (observation, reward, terminated, truncated, info).
source method SimpleMultiObsEnv.render(mode: str = 'human') → None
Prints the log of the environment.
Parameters
-
mode : str
-
mode : str — The render mode to use.
source method SimpleMultiObsEnv.reset(*, seed: int | None = None, options: dict | None = None) → tuple[dict[str, np.ndarray], dict]
Resets the environment state and step count and returns reset observation.
Parameters
-
seed : int | None — Random seed for reproducibility.
-
options : dict | None — Additional options passed to the environment reset.
Returns
-
observation dict {'vec' — ..., 'img': ...}