MT19937 is a C++ pseudorandom number engine based on the Mersenne Twister algorithm. It produces a long repeating sequence with period 2^19937−1, making it far more useful than a generator that alternates between two values. section 3.2.1
Use an engine with a seed and a distribution. A fixed seed reproduces the same sequence, which helps simulations and testing; random_device can instead provide a seed intended to vary between runs. uniform_int_distribution then maps engine output into a requested range. section 3.2.1 section 3.2.2
A number for a guessing game
Create random_device rd, initialize std::mt19937 engine(rd()), create std::uniform_int_distribution<int> dist(1, 100), and return dist(engine). Call the function from a guessing game to choose its hidden number. section 3.2.2
Listing 3.9 Generating a single random number
int some_random_number()
{
std::random_device rd; #1
std::mt19937 engine(rd()); #2
std::uniform_int_distribution<int> dist(1, 100); #3
return dist(engine); #4
}
Shows the complete engine, seed, distribution, and generated-value setup for one random integer. section 3.2.2

