#include <iostream>
#include <chrono>
#include <random>
#include <array>
#include <cmath>
int main()
{
// obtain a seed from the system clock
unsigned seed = (unsigned) (std::chrono::system_clock::now().time_since_epoch().count());
// mt19937 is a standard mersenne_twister_engine
std::mt19937 generator(seed);
// discard some values for better randomization
generator.discard(generator.state_size);
// set a distribution range (0 - 5) [dice roll - 1]
std::uniform_int_distribution<unsigned> distribution(0, 5);
// create an array to hold the die rolls
std::array<unsigned, 6> die_rolls = { 0 };
std::cout << "How many rolls? ";
unsigned number_rolls;
std::cin >> number_rolls;
std::cout << "\n";
for (unsigned loop = 0; loop < number_rolls; loop++)
{
// roll a die
unsigned dots = distribution(generator);
// add the roll to the vector
die_rolls[dots]++;
// these two steps could have been combined:
// die_rolls[distribution(generator)]++;
}
// output results
for (unsigned loop = 0; loop < die_rolls.size(); loop++)
{
std::cout << "Score " << (loop + 1) << ": tally = " << die_rolls[loop] << "\tpercentage = " << (unsigned) std::round(100.0 * die_rolls[loop] / number_rolls) << "\n";
}
}