Probably this is because you act in identical way: create the brand new
rd
and
genEngine
objects
each time you need a random value. You need to create and initialize these objects only once in the whole life cycle of your process. For example, create such objects in
main
and pass the pointer to this
genEngine
, or whatever you need to use, to your
randomize
as yet another parameter.
You can find correct code sample here:
http://en.cppreference.com/w/cpp/numeric/random[
^].
Note that the objects
std::random_device rd
and
std::mt19937 e2
are constructed/initialized only once, in
main
.
For understanding the effect of generation of identical random value, pay attention for the term:
pseudo-random:
https://en.wikipedia.org/wiki/Pseudorandom_number_generator[
^].
—SA