So, I'm debugging a bit of code that should work, but my computer hates me. What am I doing wrong?
In my main() function, I've got the simplest of loops:
Then, a bit further along, I've got the offending function:Code:for(int z = 0; z < nGenerations; z++) ParseData(nGridWidth, nGridHeight, dScore, gridInfo);
Here's the problem: The first time the function ParseData() is called, everything seems to be working fine. I get a set of (pseudo)random numbers that are good enough for my purposes. However, every subsequent call to the function gives me the same sequence of numbers. I could call the thing 10,000 times, and still get the same results. What's up with that?Code:int ParseData(int nGridWidth, int nGridHeight, double dScore[], vector <vector <sGrid> >& gridInfo) { int nCrossPoint; srand((unsigned)time(NULL)); for(int j = 0; j < rand() % 25 + 1; j++) { rand(); } for(int i = 0; i < nGridWidth / 2; i++) { nCrossPoint = rand() % nNumGenes; cout << nCrossPoint << endl; } return 0; }



LinkBack URL
About LinkBacks


