... I wasn't actually calling the right generator

This commit is contained in:
2024-02-08 17:04:33 -08:00
parent ef1c014575
commit 00ed414b1a
6 changed files with 66 additions and 68 deletions

View File

@ -1,4 +1,5 @@
use board::Board;
use pico_rng::PicoRng;
use ruleset::Ruleset;
use seen::Seen;
@ -6,12 +7,19 @@ use crate::smart_dealer::Deal;
mod board;
mod ruleset;
mod pico_rng;
mod seen;
mod smart_dealer;
mod zobrist;
fn main() {
let mut rng = PicoRng::srand(0x20000);
for _ in 0..10 {
println!("{}", rng.rnd(0x10000));
}
return;
let ruleset = Ruleset {
n_slots: 11,
n_suits: 5,

View File

@ -0,0 +1,26 @@
pub struct PicoRng {
hi: u32,
lo: u32
}
impl PicoRng {
// https://www.lexaloffle.com/bbs/?tid=51113
pub fn srand(seed: u32) -> PicoRng {
let mut rng = if seed == 0 {
PicoRng { hi: 0x60009755, lo: 0xdeadbeef }
} else {
PicoRng { hi: seed ^ 0xbead29ba, lo: seed }
};
for _ in 0..0x20 {
rng.rnd(0x10000);
}
return rng
}
pub fn rnd(&mut self, n: u32) -> u32 {
self.hi = self.hi.rotate_left(0x10).wrapping_add(self.lo);
self.lo += self.hi;
return self.hi % n
}
}