Table of Contents

Interface IInteractiveEnvViewer

Namespace
Gym.Environments
Assembly
Gym.dll

A viewer whose window also reports the user's input, as SDL reports a pygame window's and GLFW a MuJoCo viewer's: keys, the close button, resizes and the mouse. Gym.Rendering.Display pumps the keys, the close button and resizes into pygame's event queue (Gym.Rendering.EventQueue), which is how Gym.Utils.Play lets a person play an env from the keyboard; a MuJoCo env's human window reads all of it for Gymnasium's viewer controls (DR-70: orbit, pan and zoom with the mouse, the keys of its menu).

public interface IInteractiveEnvViewer : IEnvViewer, IDisposable
Inherited Members
Extension Methods

Remarks

A viewer reports nothing until BeginInput(), so the human-mode windows of envs keep their behaviour: in particular their close button keeps closing them. After it, the viewer buffers its input (its UI thread adds, the thread that plays takes) and the close button only reports Close, as a pygame window stays open after its close button until the program quits; CloseEnvironment() still closes it.

The built-in Avalonia and WinForms viewers implement it; NullEnvViewer does not (a headless run is driven by events posted to the queue instead, as Gymnasium's own tests post them). An implementation of before the mouse joined the contract simply never reports the mouse kinds, which every reader tolerates.

Methods

BeginInput()

Starts buffering input; from now on the close button reports Close instead of closing the window. Calling it again does nothing more.

void BeginInput()

TakeInput()

Takes the input buffered since the last call, oldest first; safe to call from any thread.

IReadOnlyList<ViewerInput> TakeInput()

Returns

IReadOnlyList<ViewerInput>

The inputs, empty when there are none; the caller owns the list.