I am currently having an issue where my RNG is always giving me the same number - even when I am (supposedly) seeding the value every time.
the code in the class is:
int RandomNumberGenerator()
{
std::mt19937 engine;
auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
engine.seed((unsigned long)seed);
std::uniform_int_distribution<int> distribution(0, 100);
return distribution(engine);
}
And the code calling it is:
vector<int> iv;
generate_n(back_inserter(iv), 5, RandomNumberGenerator);
cout << "\nVector content: ";
copy(iv.begin(), iv.end(), ostream_iterator<int>(cout, " "));
Surely each time the generate_n function
Aucun commentaire:
Enregistrer un commentaire