Skip to content

Instantly share code, notes, and snippets.

@theeasiestway
Last active May 8, 2020 10:13
Show Gist options
  • Save theeasiestway/768597c41f3b15c7b13bae2408317973 to your computer and use it in GitHub Desktop.
Save theeasiestway/768597c41f3b15c7b13bae2408317973 to your computer and use it in GitHub Desktop.
#include <random>
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(minValue, maxValue); // guaranteed unbiased
int randomInt = uni(rng);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment