Delegate EnvViewerFactory
- Namespace
- Gym.Environments
- Assembly
- Gym.dll
Creates the window an env renders into in render_mode="human" (Gymnasium's pygame display), synchronously
(DR-85): envs call it once, on their first human render, with the frame size and a title, and use the viewer it
returns at once. Set one app-wide through Gymnasium.HumanViewerFactory, or per env through its
viewer_factory argument (DR-20).
public delegate IEnvViewer EnvViewerFactory(int width, int height, string? title = null)
Parameters
widthintThe window's client width, the frame's width in pixels.
heightintThe window's client height, the frame's height in pixels.
titlestringThe window's title, or null for the viewer's default.
Returns
- IEnvViewer
The viewer, its window up: an IEnvViewer, or an IAsyncEnvViewer when the viewer also offers the asynchronous path (one factory creates either).
- Extension Methods
Remarks
Usually a static Factory member of the viewer class: AvaloniaEnvViewer.Factory,
WinFormEnvViewer.Factory, NullEnvViewer.Factory.
Footgun: the factory runs on the env's thread and returns only once the window exists. A UI framework's factory must therefore hand the creation to its own UI thread and wait for it there (the built-in ones do, with the framework's synchronous invoke), never block that UI thread on the env's thread, or the two deadlock.