pub struct SimRng { /* private fields */ }Expand description
The seeded simulation RNG, kept in the game’s state.
Implementations§
Source§impl SimRng
impl SimRng
Sourcepub fn roll_percent(&mut self) -> u8
pub fn roll_percent(&mut self) -> u8
A uniform integer in 0..=99. Rejection sampling: draws that would
make low values more likely (the top 2^32 mod 100 values) are
thrown away and redrawn, at most 16 times. Each draw is
rejected with chance 96 / 2^32, so the cap is never reached in
practice; it only guarantees the loop ends.
Sourcepub fn roll_below(&mut self, n: u32) -> u32
pub fn roll_below(&mut self, n: u32) -> u32
A uniform integer in 0..n (0 when n is 0). Rejection sampling
as in Self::roll_percent: draws at or above the largest multiple
of n that fits in 2^32 are redrawn, at most 16 times.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SimRng
impl<'de> Deserialize<'de> for SimRng
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for SimRng
Source§impl JsonSchema for SimRng
impl JsonSchema for SimRng
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl RandomSource for SimRng
impl RandomSource for SimRng
Source§fn roll_percent(&mut self) -> u8
fn roll_percent(&mut self) -> u8
A uniform, unbiased integer in
0..=99.Source§fn roll_below(&mut self, n: u32) -> u32
fn roll_below(&mut self, n: u32) -> u32
A uniform, unbiased integer in
0..n. n must be at least 1; 0
gives 0.impl StructuralPartialEq for SimRng
Auto Trait Implementations§
impl Freeze for SimRng
impl RefUnwindSafe for SimRng
impl Send for SimRng
impl Sync for SimRng
impl Unpin for SimRng
impl UnsafeUnpin for SimRng
impl UnwindSafe for SimRng
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