pub struct DetRng { /* private fields */ }Expand description
Deterministic pseudo-random generator keyed by simulation coordinates.
Two constructions with identical (seed, tick, system, salt) inputs
yield identical sequences on any machine and thread count - unlike a
thread-local RNG, whose per-agent draws depend on Rayon’s run-to-run
work-stealing decisions. The sequence is the canonical splitmix64 stream
over the derived seed.
Implementations§
Source§impl DetRng
impl DetRng
Sourcepub fn from_context(context: RunContext, salt: u64) -> Self
pub fn from_context(context: RunContext, salt: u64) -> Self
Creates a generator keyed by the deterministic run context and a caller-chosen salt.
Use a salt that identifies the logical draw site — an entity’s raw id,
an agent index, or a (chunk, row) encoding — so distinct agents get
independent streams within the same system and tick.
Sourcepub fn next_below(&mut self, upper: u64) -> u64
pub fn next_below(&mut self, upper: u64) -> u64
Returns a value in [0, upper) via fixed-point scaling.
Returns 0 when upper == 0. The scaling introduces a bias of at
most upper / 2^64, negligible for simulation-scale ranges.
Sourcepub fn next_index(&mut self, upper: usize) -> usize
pub fn next_index(&mut self, upper: usize) -> usize
Returns a usize index in [0, upper); 0 when upper == 0.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DetRng
impl RefUnwindSafe for DetRng
impl Send for DetRng
impl Sync for DetRng
impl Unpin for DetRng
impl UnsafeUnpin for DetRng
impl UnwindSafe for DetRng
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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