Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: AJA on Thu 25/05/2006 23:28:39

Title: Randomizing random numbers (SOLVED)
Post by: AJA on Thu 25/05/2006 23:28:39
I have this problem that the random numbers I store into global variables aren't regenerated when the game restarts. Any ideas?

Btw, I assign the values in the first room of the game after the restart point.
Title: Re: Random numbers and restart
Post by: Kweepa on Fri 26/05/2006 01:03:09
What do you mean, they aren't regenerated?
You mean they are the same value?
It's probably because the random number generator is reset when the game is restarted, so it produces the same values again.
Try using the current time to randomise the sequence.

DateTime *dt = DateTime.Now;
int i = 0;
while (i < dt.Second)
{
  int dummy = Random(1);
  i++;
}
// your code here

Title: Re: Random numbers and restart
Post by: AJA on Fri 26/05/2006 03:23:39
Hey, that worked like a charm! Thanks! :D