[−]Struct rltk::RandomNumberGenerator
Methods
impl RandomNumberGenerator
pub fn new() -> RandomNumberGenerator
Creates a new RNG from a randomly generated seed
pub fn seeded(seed: u64) -> RandomNumberGenerator
Creates a new RNG from a specific seed
pub fn rand<T>(&mut self) -> T where
Standard: Distribution<T>,
Standard: Distribution<T>,
Returns a random value of whatever type you specify
pub fn range<T>(&mut self, min: T, max: T) -> T where
T: SampleUniform,
T: SampleUniform,
Returns a random value in the specified range, of type specified at the call site. This is INCLUSIVE of the first parameter, and EXCLUSIVE of the second. So range(1,6) will give you numbers from 1 to 5.
pub fn roll_dice(&mut self, n: i32, die_type: i32) -> i32
Rolls dice, using the classic 3d6 type of format: n is the number of dice, die_type is the size of the dice.
pub fn next_u64(&mut self) -> u64
pub fn roll(&mut self, dice: DiceType) -> i32
pub fn roll_str<S>(&mut self, dice: S) -> Result<i32, DiceParseError> where
S: ToString,
S: ToString,
pub fn random_slice_index<T>(&mut self, slice: &[T]) -> Option<usize>
pub fn random_slice_entry<T>(&mut self, slice: &'a [T]) -> Option<&'a T>
Auto Trait Implementations
impl RefUnwindSafe for RandomNumberGenerator
impl Send for RandomNumberGenerator
impl Sync for RandomNumberGenerator
impl Unpin for RandomNumberGenerator
impl UnwindSafe for RandomNumberGenerator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,