Skip to content

Visualization

Visualizer

Visualizer(env_arg, env_params_arg, state_seq_arg, reward_seq_arg=None)

Animate a sequence of environment states with Matplotlib.

Supported environments are the classic control tasks (rendered through Gymnasium, which requires the visualize extra), Catch-bsuite, the MinAtar games, Pong-misc, PointRobot-misc, MetaMaze-misc and FourRooms-misc. Other environments are not drawn.

Parameters:

  • env_arg (Environment) –

    Environment that produced the states.

  • env_params_arg (EnvParams) –

    Environment parameters used for the rollout.

  • state_seq_arg (list[EnvState]) –

    List of environment states, one per frame.

  • reward_seq_arg (Array | None, default: None ) –

    Sequence with one value per frame, shown in the title as the return so far; typically the cumulative reward.

animate

animate(save_fname: str | None = 'test.gif', view: bool = False)

Render the animation and optionally save or show it.

The figure is closed afterwards.

Parameters:

  • save_fname (str | None, default: 'test.gif' ) –

    Output file. A .gif name is written with Pillow, any other extension with the default Matplotlib writer. None skips saving.

  • view (bool, default: False ) –

    Whether to show the animation in a window for three seconds.