Module Fehu.Render

Visualization primitives.

image is the standard frame type for rgb-rendered environments. rollout runs a policy and feeds rendered frames to a user-provided sink.

Pixel formats

module Pixel : sig ... end

Images

type image = {
  1. width : int;
    (*

    Width in pixels.

    *)
  2. height : int;
    (*

    Height in pixels.

    *)
  3. pixel_format : Pixel.format;
    (*

    Pixel layout.

    *)
  4. data : (int, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t;
    (*

    Raw pixel data of length width * height * channels.

    *)
}

The type for rendered frames.

val image : width:int -> height:int -> ?pixel_format:Pixel.format -> (int, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> image

image ~width ~height data constructs a frame. pixel_format defaults to Rgb.

Raises Invalid_argument if Bigarray.Array1.dim data does not equal width * height * channels.

Rollout

val rollout : ('obs, 'act, image) Env.t -> policy:('obs -> 'act) -> steps:int -> sink:(image -> unit) -> unit -> unit

rollout env ~policy ~steps ~sink () runs policy in env for up to steps steps. Each rendered frame is passed to sink. The environment is reset at the start and on episode boundaries.

Recording

val on_render : sink:(image -> unit) -> ('obs, 'act, image) Env.t -> ('obs, 'act, image) Env.t

on_render ~sink env wraps env so that every rendered frame after Env.reset and Step results is passed to sink. The wrapper is transparent: observations, actions, rewards, and termination signals pass through unchanged.