dimanche 12 août 2018

C++: How to generate random numbers while excluding numbers from a given cache

So in c++ I'm using mt19937 engine and the uniform_int_distribution in my random number generator like so:

#include <random>
#include <time.h>

int get_random(int lwr_lm, int upper_lm){

std::mt19937 mt(time(nullptr));
std::uniform_int_distribution<int> dist(lwr_lm, upper_lm);
return dist(mt);

}

What I need is to alter the above generator such that there is a cache that contains a number of integers I need to be excluded when I use the above generator over and over again. How do I alter the above such that I can achieve this?




Aucun commentaire:

Enregistrer un commentaire