blob: ae8cae6b9baecad02c50100e7b255ef52a5c0df3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
//! Implements rng using the xoshiro256++ algorithm
use rand::rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro256PlusPlus;
/// Deterministic pseudo random number generator.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DungeonRng(Xoshiro256PlusPlus);
impl SeedableRng for DungeonRng {
// Fix to 256 bits. Changing this is a breaking change!
type Seed = <Xoshiro256PlusPlus as SeedableRng>::Seed;
#[inline]
fn from_seed(seed: Self::Seed) -> Self {
Self(Xoshiro256PlusPlus::from_seed(seed))
}
#[inline]
fn seed_from_u64(state: u64) -> Self {
Self(Xoshiro256PlusPlus::seed_from_u64(state))
}
}
impl RngCore for DungeonRng {
#[inline]
fn next_u32(&mut self) -> u32 {
self.0.next_u32()
}
#[inline]
fn next_u64(&mut self) -> u64 {
self.0.next_u64()
}
#[inline]
fn fill_bytes(&mut self, dst: &mut [u8]) {
self.0.fill_bytes(dst);
}
}
|