#[repr(C)]pub struct VTable {Show 14 fields
pub abi_version: u32,
pub num_modules: extern "C" fn() -> usize,
pub module_name: extern "C" fn(i: usize, len: *mut usize) -> *const u8,
pub create: unsafe extern "C" fn(module: *const u8, len: usize, num_envs: usize, seed: i64) -> *mut c_void,
pub destroy: unsafe extern "C" fn(env: *mut c_void),
pub describe: unsafe extern "C" fn(env: *const c_void, len: *mut usize) -> *const u8,
pub num_envs: unsafe extern "C" fn(env: *const c_void) -> usize,
pub num_threads: unsafe extern "C" fn(env: *const c_void) -> usize,
pub set_num_threads: unsafe extern "C" fn(env: *mut c_void, threads: usize),
pub reset: unsafe extern "C" fn(env: *mut c_void, has_seed: bool, seed: i64),
pub obs_into: unsafe extern "C" fn(env: *const c_void, out: *mut f32, len: usize),
pub step: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, final_obs: *mut f32, obs_len: usize),
pub legal_action_masks: unsafe extern "C" fn(env: *const c_void, out: *mut bool, len: usize) -> bool,
pub step_without_final: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, obs_len: usize),
}Expand description
The functions of a library of compiled vector environments. The
environments are opaque pointers made by create and freed by
destroy; strings are UTF-8 bytes with their length.
Fields§
§abi_version: u32ABI_VERSION of the library.
num_modules: extern "C" fn() -> usizeThe number of environments (modules) in the library.
module_name: extern "C" fn(i: usize, len: *mut usize) -> *const u8The name of module i, with its length in len.
create: unsafe extern "C" fn(module: *const u8, len: usize, num_envs: usize, seed: i64) -> *mut c_voidCreates num_envs environments of a module and resets them, or
returns null for an unknown module.
destroy: unsafe extern "C" fn(env: *mut c_void)Frees environments made by create.
describe: unsafe extern "C" fn(env: *const c_void, len: *mut usize) -> *const u8A JSON description of the environments (name, num_actions,
obs_shape, action_space), valid while they live.
num_envs: unsafe extern "C" fn(env: *const c_void) -> usizeThe number of environments.
num_threads: unsafe extern "C" fn(env: *const c_void) -> usizeThe number of threads that step them.
set_num_threads: unsafe extern "C" fn(env: *mut c_void, threads: usize)Changes the number of threads.
reset: unsafe extern "C" fn(env: *mut c_void, has_seed: bool, seed: i64)Starts new episodes (from seed if has_seed).
obs_into: unsafe extern "C" fn(env: *const c_void, out: *mut f32, len: usize)Writes the observations (len floats).
step: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, final_obs: *mut f32, obs_len: usize)Steps every environment: the actions are kind 0 (discrete,
i32), 1 (multi-discrete, i32, dim per environment), or 2
(continuous, f32, dim per environment), len elements at
actions; the outputs are num_envs rewards and flags and
obs_len floats of observations and final observations.
legal_action_masks: unsafe extern "C" fn(env: *const c_void, out: *mut bool, len: usize) -> boolWrites the legal action masks (len flags) and returns true, or
returns false if the environment has none.
step_without_final: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, obs_len: usize)Steps every environment as step does, without the final
observations (the environments do not compute them): the outputs are
num_envs rewards and flags and obs_len floats of observations.