rust_qrng 0.1.2

Tsotchkes quantum random number generator library with cryptographic, financial, and gaming applications converted to Rust
Documentation
// filepath: rust_qrng/src/games/quantum_dice.rs

pub struct QuantumDice {
    quantum_rng: crate::QuantumRNG,
}

impl QuantumDice {
    pub fn new() -> Self {
        QuantumDice {
            quantum_rng: crate::QuantumRNG::new(),
        }
    }

    pub fn roll_d6(&mut self) -> u8 {
        self.quantum_rng.generate_range_u64(1, 6) as u8
    }

    pub fn roll_d20(&mut self) -> u8 {
        self.quantum_rng.generate_range_u64(1, 20) as u8
    }

    pub fn roll_custom(&mut self, sides: u32) -> u32 {
        if sides == 0 {
            return 0;
        }
        self.quantum_rng.generate_range_u64(1, sides as u64) as u32
    }

    pub fn roll_multiple(&mut self, count: usize, sides: u32) -> Vec<u32> {
        let mut results = Vec::with_capacity(count);
        for _ in 0..count {
            results.push(self.roll_custom(sides));
        }
        results
    }

    pub fn quantum_coin_flip(&mut self) -> bool {
        self.quantum_rng.generate_random_number() >= 0.5
    }

    pub fn roll(&mut self) -> u32 {
        self.quantum_rng.generate_range_u64(1, 6) as u32
    }
}

pub fn roll() -> u32 {
    let mut dice = QuantumDice::new();
    dice.roll()
}