Cmonkey123
Wanderer
Random Class
The System.Random class provided in .NET doesn't seem to be all that random...
I have a method that uses this class, it it always produces the same numbers:
The planetPopPer values aren't important, I don't have any problems with it... but it seems that no matter how I use this method it produces the same number 99% of the time, unless I completely restart the program.
Am I using the method improperly or is there another, possibly better, method that I could use to generate random numbers?
Any help would be greatly appreciated.
The System.Random class provided in .NET doesn't seem to be all that random...
I have a method that uses this class, it it always produces the same numbers:
Code:
private void CalculatePop()
{
Random rand = new Random();
//random percentages used to calc long values
int randPopNotCiv = rand.Next( planetPopPer[0] - 1, planetPopPer[1] + 1 );
int randPopNotCont = rand.Next( planetPopPer[2] - 1, planetPopPer[3] + 1 );
int randPopPoor = rand.Next( planetPopPer[4] - 1, planetPopPer[5] + 1 );
int randPopDiseasednc = rand.Next( planetPopPer[6] - 1, planetPopPer[7] + 1 );
int randPopDiseasedp = rand.Next( planetPopPer[8] - 1, planetPopPer[9] + 1 );
planetPopNotCiv = Math.Floor( ( planetPop * randPopNotCiv ) / 100 );
planetPopNotCont = Math.Floor( ( planetPop * randPopNotCont ) / 100 );
planetPopPoor = Math.Floor( ( planetPop * randPopPoor ) / 100 );
planetPopDiseased = Math.Floor( ( ( planetPop * randPopDiseasednc ) / 100 ) + ( ( planetPop * randPopDiseasedp ) / 100 ) );
}
The planetPopPer values aren't important, I don't have any problems with it... but it seems that no matter how I use this method it produces the same number 99% of the time, unless I completely restart the program.
Am I using the method improperly or is there another, possibly better, method that I could use to generate random numbers?
Any help would be greatly appreciated.