pub struct SplitMix64 { /* private fields */ }Expand description
Tiny deterministic PRNG. State is one u64; output passes the obvious goodness tests (BigCrush-ish) and is more than enough for upgrade-tree procgen. Not for cryptography.
Implementations§
Source§impl SplitMix64
impl SplitMix64
pub fn new(seed: u64) -> Self
Sourcepub fn from_coords(seed: u64, x: i32, y: i32, salt: u64) -> Self
pub fn from_coords(seed: u64, x: i32, y: i32, salt: u64) -> Self
Combine a base seed with three coordinate-like ints into a fresh
PRNG state. salt lets adjacent call sites avoid stepping on each
other (e.g. “noise lookup” vs “edge roll” at the same lot).
pub fn next_u64(&mut self) -> u64
Sourcepub fn next_f64(&mut self) -> f64
pub fn next_f64(&mut self) -> f64
Returns a value in [0.0, 1.0). 53-bit mantissa for double precision.
Sourcepub fn range_usize(&mut self, max: usize) -> usize
pub fn range_usize(&mut self, max: usize) -> usize
Returns an integer in [0, max). Trivial modulo bias is acceptable
for procgen — the bias for max < 1e9 is well below any other source
of variance in the system.
Sourcepub fn bool_with_prob(&mut self, p: f64) -> bool
pub fn bool_with_prob(&mut self, p: f64) -> bool
True with probability p.
Auto Trait Implementations§
impl Freeze for SplitMix64
impl RefUnwindSafe for SplitMix64
impl Send for SplitMix64
impl Sync for SplitMix64
impl Unpin for SplitMix64
impl UnsafeUnpin for SplitMix64
impl UnwindSafe for SplitMix64
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more