So, I was wondering how random rand() truly is, and, as it turns out, it is not very random at all.
For example, this code generates a random number between 1 - 6, and adds that occurrence to one of six counters (depending on what that number is).
#include <iostream>
int main()
{
int a = 0; int b = 0; int c = 0;
int d = 0; int e = 0; int f = 0;
for (int x = 0; x < 6000; x++) {
srand(time(NULL));
int i = 1 + rand() % 6;
if (i == 1) {a++;}
if (i == 2) {b++;}
if (i == 3) {c++;}
if (i == 4) {d++;}
if (i == 5) {e++;}
if (i == 6) {f++;}
}
std::cout << a << "\n" << b << "\n" << c << "\n";
std::cout << d << "\n" << e << "\n" << f << std::endl;
return 0;
}
However, here are some of the results I got when running the code:
Test #1:
6000
0
0
0
0
0
Test #2:
0
0
0
0
6000
0
Test #3:
0
6000
0
0
0
0
Anyway, I was wondering if there was a better way to generate random numbers, or if there is a library that can generate more random numbers than I currently am. Thanks.