Challenge 23 eod.
This commit is contained in:
@@ -18,8 +18,12 @@ impl MT19937 {
|
||||
mt
|
||||
}
|
||||
|
||||
pub fn splice(&mut self, state: Vec<u32>) {
|
||||
self.mt = state;
|
||||
self.index = 624;
|
||||
}
|
||||
|
||||
pub fn seed(&mut self, seed: u32) {
|
||||
self.index = N;
|
||||
const F: u32 = 1812433253;
|
||||
self.mt[0] = seed;
|
||||
for i in 1..N {
|
||||
@@ -27,14 +31,14 @@ impl MT19937 {
|
||||
+ Wrapping(i as u32))
|
||||
.0;
|
||||
}
|
||||
self.twist();
|
||||
}
|
||||
|
||||
pub fn extract_number(&mut self) -> u32 {
|
||||
if self.index >= N {
|
||||
if self.index > N {
|
||||
panic!("Generator was never seeded");
|
||||
}
|
||||
if self.index == N {
|
||||
self.twist();
|
||||
} else if self.index > N {
|
||||
panic!("Generator was never seeded");
|
||||
}
|
||||
|
||||
const S: u32 = 7;
|
||||
|
||||
Reference in New Issue
Block a user