1

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?

9
  • Why is the true random numbers request so strict? If you're going to do a simulation most of the time you can manage to have decent results using pseudo-random, have you explored any of the techniques without a satisfactory result? Commented Jul 17, 2013 at 17:29
  • Why do you want to use random.org? A decently seeded crypto PRNG is almost always a better choice. Commented Jul 17, 2013 at 17:41
  • I have checked out the LFSR idea and it seems like that might be ok, but the wording in the specification document says "true random" and i know a lot of people have used random.org in the past for this assignment
    – tim
    Commented Jul 17, 2013 at 17:59
  • 4
    @DanielA.White The laws of physics disagree with you.
    – Casey
    Commented Jul 17, 2013 at 18:13
  • 4
    @DanielA.White No offense, but "true randomness" has absolutely nothing to do with finiteness of your space, but rather with determism of the laws that rule your space. Example: an electron orbiting around a nucleus has finite possible states, but a measure of its quantum state would give you a purely random result (weighted by the probability given by the quantum state). The computer of the OP most likely lies in our physical space, which appears to be quantic according to state-of-the-art research. Hence, true random is possible (e.g.: 50th digit of the temperature of the CPU). Commented Jul 17, 2013 at 19:38

3 Answers 3

4

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.

2
  • Thanks! And before I spend a long time reading through it and working out how to make it do exactly what I want i was wondering if there was a tutorial that explains how to use the library exactly? If not no problem :)
    – tim
    Commented Jul 17, 2013 at 20:08
  • @tim I don't see any tutorials, but there are a couple of examples linked in the README.md file. Commented Jul 17, 2013 at 20:13
0

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.

-2

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.

3
  • Please expand on your statement “Just multiply some pseudo-random data with this truly random set, and you have a truly random product.” Even better, provide a working example showing how to do this in C++, per the language tag on the question.
    – pjs
    Commented Oct 6 at 18:34
  • 2
    Won't the results stop being truly random as soon as they are used more than once? It seems like a static array of truly-random numbers would be equivalent to a one-time pad, or a (longer) seed for a PRNG at best. Commented Oct 6 at 18:43
  • 1
    @JeremyFriesner: I'll just point to the standard answer to that question: xkcd.com/221
    – MSalters
    Commented Oct 7 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.