Expand description
(build_module / register_array_extensions) is gone — there is no engine
to register into. What remains here are the pure, typed versions of the
random helpers the util module used to expose to scripts:
rand_round, get_random_element, rand_weight, and drain_random.
count and index/weight arithmetic) but operate on native typed collections
script ports call the typed equivalents directly: rand_round delegates to
crate::mechanics::balance::rand_round_f64, and the
drain/weight draws are reproduced by opponent_generation, loop_tasks,
and currencies so their RNG sequences stay identical.
Functions§
- drain_
random - Remove and return a uniformly-random element from
vec, returningNonefloor(random_f64() * len), clamped, thenremove(idx). - get_
random_ element - Pick a uniformly-random element from
slice, returningNonefor an emptyfloor(random_f64() * len), clamped tolen - 1. - rand_
round - Stochastic round of a non-integer value. Delegates to the shared native
helper so every
rand_roundcaller draws RNG identically. - rand_
weight rand_weight: sum the weights, drawrandom_f64() * sum_weightonce, then walk the slice subtracting each weight until it goes non-positive. ReturnsNonewhen the slice is empty or all weights sum to<= 0.0(matching the oldDynamic::UNITreturn). The last element is returned as the fallback if floating-point drift leaves the accumulator positive at the end.