PDA

View Full Version : Random not generating random numbers


EdyEft
12-03-2006, 11:34 AM
First post, so if this is easly outlined somewhere please give me a heads up.

I have a simple loop (iterating 5 times), and inside that i am assigning a variable a random number from min=0 , max = 3, integer only. For some reason, I feel like the first time I call this random function I am receiving a random number, but every time after not... Can/Do you need to seed the random function with a time?

Little insight, i'm calling this from the a world event "on world start", and just trying to determine out of 2 objects, randomly which one to move. I'm only looking to get a value of 1 or 2. :confused:


Any help would be appreciated.

Thanks

ulrich200
06-10-2008, 04:12 PM
For some reason, I feel like the first time I call this random function I am receiving a random number, but every time after not...

you're right, when you set a loop to generate random numbers it does for some reason only do it the first time. right now i have no solution but i will keep looking into it

DrJim
06-10-2008, 04:26 PM
Do a search of the forum (with Google is quickest) on random number generators. You will see a description of the Alice approach and some suggestions to really randomize the initial seed of it's random number generator.

But you are both correct - unless something is done, Alice's string of "random" numbers will always be the same sequence.