Class NullEnvViewer
- Namespace
- Gym.Environments
- Assembly
- Gym.dll
A viewer that shows nothing: human mode without a window, for headless tests and servers. Since DR-20 nothing falls
back to it silently; pass Factory (as viewer_factory, or as Gymnasium.HumanViewerFactory)
to run human mode headless, where Gymnasium would need a display.
public sealed class NullEnvViewer : IAsyncEnvViewer, IEnvViewer, IDisposable
- Inheritance
-
NullEnvViewer
- Implements
- Inherited Members
- Extension Methods
Remarks
Every env shares one instance, which holds no state: disposing or closing it does nothing. The env still draws
each human frame before handing it over, and still paces itself at render_fps. It implements
IAsyncEnvViewer too (DR-85), its asynchronous calls completing at once, so headless runs exercise an
asynchronous env's path as well.
Fields
Factory
The factory to hand to envs for headless human mode. One delegate instance for the process: code that must know whether a real window would open compares a factory with it by reference.
public static readonly EnvViewerFactory Factory
Field Value
Methods
Close()
Does nothing: there is no window.
public void Close()
CloseAsync()
Does nothing: there is no window.
public ValueTask CloseAsync()
Returns
- ValueTask
A completed task.
Dispose()
Does nothing: the shared instance holds no resources.
public void Dispose()
Open(int, int, string?)
The factory's body: returns the shared instance.
public static IEnvViewer Open(int width, int height, string? title = null)
Parameters
Returns
- IEnvViewer
The shared viewer.
Render(NDArray)
Discards the frame; it is checked as the windowed viewers check it, so a headless run fails where a windowed one would.
public void Render(NDArray frame)
Parameters
frameNDArrayThe frame,
(H, W, 3); not read further.
Exceptions
- ArgumentNullException
Thrown when
frameis null.- ArgumentException
Thrown for a frame that is not
(H, W, 3).
RenderAsync(NDArray, CancellationToken)
Discards the frame at once, as Render(NDArray) does.
public ValueTask RenderAsync(NDArray frame, CancellationToken cancellationToken = default)
Parameters
frameNDArrayThe frame,
(H, W, 3); not read further.cancellationTokenCancellationTokenChecked once, before anything else.
Returns
- ValueTask
A completed task.
Exceptions
- ArgumentNullException
Thrown when
frameis null.- ArgumentException
Thrown for a frame that is not
(H, W, 3).- OperationCanceledException
Thrown when
cancellationTokenis already cancelled.
Run(int, int, string?)
The factory's body as 0.2's asynchronous factories were shaped: a completed task of the shared instance.
public static Task<IEnvViewer> Run(int width, int height, string? title = null)
Parameters
Returns
- Task<IEnvViewer>
A completed task holding the shared viewer.