Add new_with_seed method

This commit is contained in:
Gwilym Kuiper 2022-03-23 21:53:09 +00:00
parent 610722a1bf
commit 3c52f6940b

View file

@ -15,6 +15,10 @@ impl RandomNumberGenerator {
} }
} }
pub const fn new_with_seed(seed: [u32; 4]) -> Self {
Self { state: seed }
}
pub fn next(&mut self) -> i32 { pub fn next(&mut self) -> i32 {
let result = (self.state[0].wrapping_add(self.state[3])) let result = (self.state[0].wrapping_add(self.state[3]))
.rotate_left(7) .rotate_left(7)