Re: Dice rolls seem very off in Catan
Posted: 20 February 2025, 04:57
My assumption is that BGA's RNG is implemented correctly. I was not expecting to find and flaws in the code, I was just curious about the implementation, and if it "wastes" random bits or if it finds a clever way to re-use them.euklid314 wrote: ↑19 February 2025, 14:56 The game developer once posted the relevant code fragment. It was
die1 = bga_rand(1,6)
die2 = bga_rand(1,6)
If you read BGA FAQ you will learn that bga_rand calls the cryptographically safe PHP function random_int(). This RNG function is of the highest mathematical standard and is public domain. If you find a problem in this PHP function you will get worldwide media attention.
(And curiosity aside, nobody cares if pseudorandom bits are "wasted" anyway. Maybe worrying about it might make sense for something like a radioactive decay-based RNGs. I know those can generate only so many random bits per time period.)
But you saying "die1 = bga_rand(1,6)" wouldn't give me any confidence if I did suspect there was a flaw. I'd need to see the implementation of bga_rand().
(BTW, this page says that PHP's random_int() uses CryptGenRandom() under Windows and the getrandom(2) system call under Linux. I guess I'd have to look at both of them if I really wanted to see about "wasted" bits. I'm curious, but probably not curious enough.)