#include <algorithm>
#include <ctime>
#include <iostream>
#include <numeric>
#include <vector>
#include <random>
int main()
{
using namespace std;
time_t t = time(NULL);
//srand(static_cast<unsigned int>(t));
std::mt19937 randgen(t);
int simulationSize = 10000; // 1 million //lowered to 10k to run on ideone
std::uniform_int_distribution<int> dist4(0,3);
std::uniform_int_distribution<int> dist6(0,5);
// simulation 1, 4 faces on dice
cout << "Simulation 1( 4 faced dice ): " << endl;
int fourSideDicePrizes[] { 1, 1, -1, -1 };
for (int i = 0; i < 10; i++)
{
int total = 0;
for (int j = 0; j < simulationSize*100; ++j)
{
int roll = dist4(randgen);
total += fourSideDicePrizes[roll];
}
cout << total << endl;
}
cout << " -------------------------------------------------------\n\n" << endl;
// simulation 2, 6 dice
cout << "Simulation 2( 6 faced dice ): " << endl;
int sixSidedDicePrizes[] { 1, 1, -1, -1, -1, 1 };
for (int i = 0; i < 10; i++)
{
int total = 0;
for (int j = 0; j < simulationSize * 100; ++j)
{
int roll = dist6(randgen);
total += sixSidedDicePrizes[roll];
}
cout << total << endl;
}
cout << " -------------------------------------------------------\n\n" << endl;
cin.get();
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxudW1lcmljPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cmFuZG9tPgppbnQgbWFpbigpCnsKCXVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoJdGltZV90IHQgPSB0aW1lKE5VTEwpOwoJLy9zcmFuZChzdGF0aWNfY2FzdDx1bnNpZ25lZCBpbnQ+KHQpKTsKCXN0ZDo6bXQxOTkzNyByYW5kZ2VuKHQpOwoJaW50IHNpbXVsYXRpb25TaXplID0gMTAwMDA7IC8vIDEgbWlsbGlvbiAvL2xvd2VyZWQgdG8gMTBrIHRvIHJ1biBvbiBpZGVvbmUKCXN0ZDo6dW5pZm9ybV9pbnRfZGlzdHJpYnV0aW9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