Enum RenderMode
The render modes Gymnasium's envs know, as an enum (DR-84, DR-93): what the env constructors, Make and
MakeVec take beside Gymnasium's string, new CartPoleEnv(RenderMode.RgbArray) being
new CartPoleEnv(renderMode: "rgb_array"). Each member stands for its Gymnasium string
(Name(RenderMode)), and Parse(string?) and TryParse(string?)
read a string back.
[PyEnum(null)]
public enum RenderMode
- Extension Methods
Fields
[PyValue("human")] Human = 0"human": the env draws into a window duringStepandReset, andRender()returns None.[PyValue("rgb_array")] RgbArray = 1"rgb_array":Render()returns the frame, an(H, W, 3)uint8 array (RenderResult.Rgb).[PyValue("ansi")] Ansi = 2"ansi":Render()returns the frame as text (RenderResult.Ansi), the toy_text grids' mode.[PyValue("depth_array")] DepthArray = 3"depth_array":Render()returns a depth image (RenderResult.Depth), the MuJoCo envs' mode.[PyValue("rgbd_tuple")] RgbdTuple = 4"rgbd_tuple":Render()returns the frame and its depth image together (RenderResult.RgbDepth), the MuJoCo envs' mode.[PyValue("state_pixels")] StatePixels = 5"state_pixels": CarRacing's 96×96 frame, the image its observations are.[PyValue("rgb_array_list")] RgbArrayList = 6"rgb_array_list": every RgbArray frame since the lastRender()or reset, whichmakecollects withRenderCollection.[PyValue("ansi_list")] AnsiList = 7"ansi_list": every Ansi frame since the lastRender()or reset, collected byRenderCollection.[PyValue("depth_array_list")] DepthArrayList = 8"depth_array_list": every DepthArray frame since the lastRender()or reset, collected byRenderCollection.[PyValue("rgbd_tuple_list")] RgbdTupleList = 9"rgbd_tuple_list": every RgbdTuple frame since the lastRender()or reset, collected byRenderCollection.[PyValue("state_pixels_list")] StatePixelsList = 10"state_pixels_list": every StatePixels frame since the lastRender()or reset, collected byRenderCollection.
Remarks
The string stays the canonical form (DR-93): RenderMode, an env's metadata["render_modes"],
a spec's kwargs and the attribute protocol hold Gymnasium's strings, because Gymnasium accepts render modes no enum
can list: make("CartPole-v1", render_mode="no-render-mode") warns and builds the env, and a user's env may
declare modes of its own. To compare an env's mode with a member, parse it:
RenderModes.TryParse(env.RenderMode) == RenderMode.RgbArray, or compare the strings
(env.RenderMode == RenderModes.RgbArray).
Footgun: inside a class derived from Env, the simple name RenderMode in an expression is the
inherited RenderMode property (a string), so RenderMode.Human does not compile there; write
Gym.Envs.RenderMode.Human. As a parameter or variable type the name is this enum everywhere.
Passed in a kwargs dictionary or anonymous object (new { render_mode = RenderMode.Human }), a member becomes
its string (ToPython(object?)), so specs record what Gymnasium's do.
Reference: gymnasium/core.py (Env.render).