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 ... endImages
type image = {width : int;(*Width in pixels.
*)height : int;(*Height in pixels.
*)pixel_format : Pixel.format;(*Pixel layout.
*)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 ->
imageimage ~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 ->
unitrollout 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
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.