Reputation: 319
I am trying to make a dice rolling console application in C++ and I need to implement true random numbers (yes true not pseudo) which is proving to be fairly difficult.
I have heard that Random.org has a c++ library but the only link that I can find is broken and I cant seem to find any documentation on it.
I am trying to allow the user to select a dice from 4, 6, 8 10 and 20 sided dice and roll 1-100 of the selected die. The results are then displayed.
Does anyone know how I can access random numbers between x-y from random.org or something similar?
Upvotes: 1
Views: 2664
Reputation: 1714
You don't really need random.org for this.
There is a non-deterministic "random device" built into every modern computer. It accumulates randomness/entropy from your hardware (access times, temperatures, timings, etc. etc.). If you draw a lot of number from this, the entropy drops (std::random_device::entropy()) and the randomness becomes less non-deterministic.
This random-device is paramount for cryptography and is a core concern in cybersecurity.
In linux the random device is mapped to /dev/random
However, in C++ it is available in a system-independent way via https://en.cppreference.com/w/cpp/numeric/random/random_device
In some implementations, you will actually get pseudo-random numbers from this BUT that are explicitly seeded from hardware randomness. Thus, for all practical purpose, are also non-deterministic.
Upvotes: 0
Reputation: 1
Just generate a random set from a true quantum number generator like Camacho Labs [https://camacholab.byu.edu/qrng][1] and integrate into a static array in your application. Just multiply some pseudo-random data with this truly random set, and you have a truly random product.
Upvotes: -2
Reputation: 405795
The URL in the link to the C++ library on the Random.org HTTP Client Archive page is malformed. It's supposed to point to doughague/random-dot-org on GitHub. You can use that to access real random number data generated via atmospheric noise.
Upvotes: 4