macroquad
macroquad copied to clipboard
Unintended behavior of rand::gen_range()
I discovered an unintended behavior of rand::gen_range()
The following code
use macroquad::prelude::*;
fn main() {
let mut count = 0;
loop {
if rand::gen_range(1, 5) == 5 {
break;
}
count += 1;
}
println!("{count}");
}
reproducibly prints 14540063
Expected behavior: loop running forever
macorquad version 0.4.4 rustc 1.75.0 compiled on Linux Mint 21
you can use rand::srand()
, something like macroquad::rand::srand(macroquad::miniquad::date::now())
should do the trick
@not-fl3 Latest quad-rand
commit fixed this, but it is not updated on crates.io.
My guess is because I did not bump up the crate version, but not I'm sure (I have no experience with publishing crates)