SpacesTrajectoryRecord

class maze.core.trajectory_recording.records.trajectory_record.SpacesTrajectoryRecord(id: Any)

Holds structured spaces records (i.e., raw actions and observations recorded during a rollout).

property actions: List[List[Dict[str, int | numpy.ndarray] | Dict[str, torch.Tensor]]]

Convenience access to all structured action dicts from this trajectory.

property actions_dicts: List[Dict[str | int, Dict[str, int | numpy.ndarray]]]

Convenience access to all structured action dicts from this trajectory.

TODO: Does not support multi agent scenarios (where the substep (dict) key is the same for all agents)

This method is only used in alpha zero though.

is_done() → bool

Convenience method for checking whether the end of this trajectory represents also the end of an episode.

stack() → StructuredSpacesRecord

Stack the whole trajectory into a single structured spaces record.

Useful for processing whole fixed-length trajectories in a single batch.

classmethod stack_trajectories(trajectories: List[SpacesTrajectoryRecord]) → SpacesTrajectoryRecord

Stack multiple trajectories, keeping the time dimension intact.

All the trajectories should be of the same length. The resulting trajectory will have the same number of steps, each being a stack of the corresponding steps of the input trajectories.

Parameters:

trajectories – Trajectories to stack.

Returns:

Trajectory record of the same lenght, consisting of stacked structured spaces records.

total_reward()

Convenience method for calculating the total reward of a given trajectory.