I've got an issue with the random number generator I'm using in C++. It's randomness is fine, but the problem is that I'm automating something that runs a few thousand times in a couple of seconds, and it's going so fast that the random numbers don't change.
If I'm manually running the code and taking a second or two in between calls to the function with the random number generator in it, it's fine. It's when it's getting called quickly that it's not changing. I understand that it's going by a clock, I believe the system clock, but it's the only random function I've used that at least gives the appearance of randomness. Is there some way I can get past this, or can someone recommend a random function that doesn't have this problem.
To be clear what I'm using, I've added a part of my code that uses the random function...
If I'm manually running the code and taking a second or two in between calls to the function with the random number generator in it, it's fine. It's when it's getting called quickly that it's not changing. I understand that it's going by a clock, I believe the system clock, but it's the only random function I've used that at least gives the appearance of randomness. Is there some way I can get past this, or can someone recommend a random function that doesn't have this problem.
To be clear what I'm using, I've added a part of my code that uses the random function...
Code:
.
.
srand((unsigned)time(NULL));
.
.
m_Value = (rand()%14)+1;
.
.
Comment