On “randomness” and my dice app

(This was originally posted on cohost)

I was asked how my dice app could produce truly random results by someone who needed to make a random selection for a research project, I wrote the following response which is way too long, but figured I’d share so I can link it next time I get a similar question:

TL;DR: For the purposes of having a defensible form of randomness with dice, get some precision casino dice and use those. Other things may be random enough but arguing so will probably be more work, and likely result in dealing with human bias about RNG and not just random bias 😉

Full answer:

In my app, dice outcomes are determined by physics simulations – the shapes roll and whichever face is the most upward-pointing is selected as the result once a die has settled.

The physics simulation system itself is deterministic, and was designed for video-game use so it likely contains optimisations and mechanisms that may be antithetical to providing randomness and I have certainly noted it introducing bias for some shapes.

However I have eliminated all bias that I’ve been capable of detecting by adjusting initial conditions of the rolls. These are randomised using a combination of human input (where dice are thrown from, and their velocity) and pseudorandom number generation (adjusting user-inputted velocity, moving faces about the physics collider (by random symmetry for face-transitive shapes, and completely shuffled for other shapes), selecting a random rotation, and also random angular velocity).

For every shape, I roll it at least 10,000*n times (where n is the number of faces the die has) without any human input, and then check the standard deviation of which faces come up to be confidant that there is no detectable bias.

Which is all to say, (aside from a couple of deliberate things a user may do) the dice in my app are very fair, and they are unpredictable.

But how random they are is not a question I can answer, nor is it one I think is important. After a certain point, it’s a problem that is more philosophical than anything else. If you know the initial conditions at the beginning of a simulated roll, you could (with a lot of work) be able to know what the result will be without looking – but the same is also true of a hypothetical perfectly fair real die (excusing some quantum weirdness that is much beyond my capability to interrogate).

A lot of people try to make a clear distinction between pseudorandom number generation, and “true” random number generation, but ultimately it comes down to how you define randomness, and what kind of randomness you need (and even then, selecting it is still a non-random human selection in the sequence of events that leads to your final result! :p). Randomness at its heart is unpredictability, so who is doing the prediction? Does it matter if it is unpredictable to a child? To you? To a supercomputer? How accurate do predictions need to be for a system to fail?

For me, randomness is an ocean of unknowable depth. You just need to pick the deepest point you can find. If you can’t see the floor when you dive (the bias in the selections you make), then you’re in the right place and won’t be limited by it.

I’ve made my app to be as deep as I possibly can make it, but for the purposes of having RNG that has the most socially and academically defensible notion of randomness, I’d just use machined casino dice. Whether that is more or less random than my app I can’t say – either way I doubt you’ll predict any outcome reliably, but real dice are closer to the dirt and noise of the universe, and casino dice are the most precisely crafted ones, as such they are the hardest to argue against being fair (although testing the fairness of real dice is another thing I can get a bee in my bonnet about – any test of sufficient magnitude will change the conditions of the test and introduce their own bias).