python-dice icon indicating copy to clipboard operation
python-dice copied to clipboard

Add optional quantum random number generator

Open saranvdev opened this issue 6 years ago • 4 comments

There are some sites with api for getting quantum random numbers, I think it'd be nice to have: https://qrng.anu.edu.au/API/api-demo.php

They're producing random numbers by reading void fluctuations or something like this. Anyway, these are 100% random numbers. Some online RPG sites are already using quantum numbers.

The only problem that I can think of, this feature will need internet connection.

saranvdev avatar Nov 09 '18 16:11 saranvdev

We could do this by optionally depending on quantumrandom, I think.

Implementing a subclass of random.Random based on that package isn't within the scope of python-dice, but I can PR it to quantumrandom and add an option to supply a custom Random instance. That would also allow users to roll dice using random.SystemRandom if they want.

calebj avatar Nov 09 '18 19:11 calebj

I've implemented a version of Random that uses quantumrandom with caching, but I'd like to add background thread fetching before posting it.

calebj avatar Nov 09 '18 20:11 calebj

I've posted the interface here. I'll work on the dice lib modification next.

calebj avatar Nov 09 '18 23:11 calebj

PR'd the quantumrandom change as lmacken/quantumrandom#22, and you can specify the random engine used by python-dice as of v2.4.0, which is live on PyPI now.

calebj avatar Nov 10 '18 01:11 calebj