Seeded pseudo-random number generator resource for Copper.
[CuRng] is a deterministic, reproducible RNG (ChaCha8) usable anywhere
[rand::Rng] is expected. It is wired into a Copper app as a
single-slot resource bundle, [CuRngBundle], via the standard resource
mechanism.
Use [prelude] to bring the normal rand sampling API into scope:
use *;
let mut rng = from_seed;
let unit_f64: f64 = rng.random;
let unit_f32: f32 = rng.random;
let noise: f64 = rng.random_range;
let enabled: bool = rng.random;
let dropout: bool = rng.random_bool;
let vector: = rng.random;
assert!;
assert!;
assert!;
let _ = ;
Example config
(
resources: [
( id: "planner_rng", provider: "cu_rng::CuRngBundle", config: {"seed": 12345} ),
],
tasks: [
( id: "planner", type: "tasks::MyPlanner",
resources: { "rng": "planner_rng.rng" } ),
],
)
On the task side, declare the binding with the resources! macro:
use *;
use resources;
use *;