Module Fehu.MetadataSource

Environment metadata describing properties and capabilities.

Metadata includes supported render modes, environment version, author information, and tags.

Environment metadata for discovery and configuration.

Metadata describes environment properties like supported render modes, version information, and authorship. It follows Gymnasium's metadata convention, enabling environment registries and documentation generation.

Usage

Create metadata for a custom environment:

  let metadata =
    Metadata.default
    |> Metadata.with_version (Some "1.0.0")
    |> Metadata.with_description (Some "CartPole balancing task")
    |> Metadata.add_render_mode "human"
    |> Metadata.add_render_mode "rgb_array"
    |> Metadata.with_render_fps (Some 50)

Check render mode support:

  if Metadata.supports_render_mode "human" metadata then
    (* render in human mode *)
Sourcetype t = {
  1. render_modes : string list;
    (*

    Available rendering modes (e.g., "human", "rgb_array")

    *)
  2. render_fps : int option;
    (*

    Frames per second for rendering, if applicable

    *)
  3. authors : string list;
    (*

    Environment authors or contributors

    *)
  4. description : string option;
    (*

    Brief environment description

    *)
  5. version : string option;
    (*

    Version string (e.g., "1.0.0")

    *)
  6. supported_vector_modes : string list;
    (*

    Supported vectorization modes

    *)
  7. tags : string list;
    (*

    Classification tags (e.g., "control", "atari")

    *)
  8. extra : Yojson.Safe.t option;
    (*

    Additional custom metadata as JSON

    *)
}

Environment metadata record.

Sourceval default : t

default is the default metadata with all fields empty or None.

Sourceval add_render_mode : string -> t -> t

add_render_mode mode metadata adds mode to supported render modes.

Common modes: "human" (display for humans), "rgb_array" (pixel array), "ansi" (text representation).

Sourceval supports_render_mode : string -> t -> bool

supports_render_mode mode metadata checks if mode is supported.

Sourceval with_render_fps : int option -> t -> t

with_render_fps fps metadata sets the rendering frame rate.

Sourceval with_description : string option -> t -> t

with_description desc metadata sets the environment description.

Sourceval with_version : string option -> t -> t

with_version version metadata sets the version string.

Sourceval with_render_modes : string list -> t -> t
Sourceval with_supported_vector_modes : string list -> t -> t
Sourceval with_authors : string list -> t -> t
Sourceval with_extra : Yojson.Safe.t option -> t -> t
Sourceval add_supported_vector_mode : string -> t -> t
Sourceval add_author : string -> t -> t

add_author name metadata adds name to the authors list.

Sourceval add_tag : string -> t -> t

add_tag tag metadata adds tag to the tags list.

Sourceval set_tags : string list -> t -> t

set_tags tags metadata replaces all tags with tags.

Sourceval to_yojson : t -> Yojson.Safe.t

to_yojson metadata serializes metadata to JSON.

Sourceval of_yojson : Yojson.Safe.t -> (t, string) result

of_yojson json deserializes metadata from JSON.

Returns Error msg if the JSON structure is invalid.