pub struct Rng { /* private fields */ }Expand description
Lightweight seeded pseudo-random number generator (xoshiro256**). Used throughout procedural generation for reproducibility.
Implementations§
Source§impl Rng
impl Rng
pub fn new(seed: u64) -> Self
Sourcepub fn range_usize(&mut self, n: usize) -> usize
pub fn range_usize(&mut self, n: usize) -> usize
Next usize in [0, n).
Sourcepub fn pick<'a, T>(&mut self, slice: &'a [T]) -> Option<&'a T>
pub fn pick<'a, T>(&mut self, slice: &'a [T]) -> Option<&'a T>
Pick a random element from a slice.
Sourcepub fn pick_weighted<'a, T>(&mut self, items: &'a [(T, f32)]) -> Option<&'a T>
pub fn pick_weighted<'a, T>(&mut self, items: &'a [(T, f32)]) -> Option<&'a T>
Pick a random element from a weighted list. Weights can be any positive f32.
Sourcepub fn gaussian(&mut self, mean: f32, stddev: f32) -> f32
pub fn gaussian(&mut self, mean: f32, stddev: f32) -> f32
Gaussian sample with given mean and stddev (Box-Muller).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rng
impl RefUnwindSafe for Rng
impl Send for Rng
impl Sync for Rng
impl Unpin for Rng
impl UnsafeUnpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.