pub fn rand_weight<'a, T>(
random: &GameRng,
weighted: &'a [(f64, T)],
) -> Option<&'a T>Expand description
rand_weight: sum the weights, draw random_f64() * sum_weight once, then
walk the slice subtracting each weight until it goes non-positive. Returns
None when the slice is empty or all weights sum to <= 0.0 (matching the
old Dynamic::UNIT return). The last element is returned as the fallback if
floating-point drift leaves the accumulator positive at the end.