Struct Random
pub struct Random { /* private fields */ }Expand description
The game’s random number generator. See the module documentation.
Implementations§
§impl Random
impl Random
pub fn new(seed: u32) -> Random
pub fn new(seed: u32) -> Random
A generator seeded with seed, as the engine seeds one.
Original: Random::Random(unsigned int), Runtime 0x1800ca740.
pub fn from_parts(index: u32, state: [u32; 624]) -> Random
pub fn from_parts(index: u32, state: [u32; 624]) -> Random
A generator restored from a save: its index, then its 624 state words.
pub fn rand_below(&mut self, n: u32) -> u32
pub fn rand_below(&mut self, n: u32) -> u32
A number from 0 to n - 1. When n is 0, it returns 0 and draws nothing.
Original: Rand(unsigned int), Runtime 0x1800ca8b0.
pub fn rand_range(&mut self, lo: i32, hi: i32) -> i32
pub fn rand_range(&mut self, lo: i32, hi: i32) -> i32
A number from lo to hi, both included.
Original: Rand(int, int), Runtime 0x1800ca5e0.
pub fn rand_tol(&mut self, t: i32) -> i32
pub fn rand_tol(&mut self, t: i32) -> i32
A number from -t to t, both included.
Original: RandTol(int), Runtime 0x1800ca610.
pub fn rand_float(&mut self) -> f32
pub fn rand_float(&mut self) -> f32
A float from 0 to 1, 1 not included: (float)u × 2⁻³².
Original: RandFloat(), Runtime 0x1800ca5b0.
pub fn rand_float_tol(&mut self) -> f32
pub fn rand_float_tol(&mut self) -> f32
A float from -1 to 1, -1 not included: 1 − (float)u × 2⁻³² × 2.
Original: RandFloatTol(), Runtime 0x1800ca870.
Trait Implementations§
impl Eq for Random
impl StructuralPartialEq for Random
Auto Trait Implementations§
impl Freeze for Random
impl RefUnwindSafe for Random
impl Send for Random
impl Sync for Random
impl Unpin for Random
impl UnsafeUnpin for Random
impl UnwindSafe for Random
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