quick question on seedRnd millisecs()
Blitz3D Forums/Blitz3D Beginners Area/quick question on seedRnd millisecs()
| ||
I'm a little confused by this. Can someone clarify something for me please. if i start the begining of my project with SeedRnd Millisecs() will that ensure that whenever I use the rnd() command it will be random numbers and not the same everytime the program starts? thx for the info. Amon |
| ||
It will be as random as its possible to get. The chances of your end-user switching on his PC (from when Millisecs() counts up from 0) and running the game at the exact millisecond twice in a row, are tantamount to impossible. Or put another way - before that happened, the end user would be more likely to win the national lottery jackpot 50 times in a row. |
| ||
Thats random enough for me. Thx GFK :) |
| ||
I would do something of this sort:SeedRnd (Millisecs() + Pi) * Pi / Pi - Millisecs() + 5.66678321 It randomizes it a bit more :D |
| ||
I would do something of this sort: No it doesn't. Its all still based on Millisecs(). Pi is always the same. 5.66678321 is always the same. The only variation is Millisecs(). SeedRnd (Millisecs() + Pi) * Pi / Pi - Millisecs() + 5.66678321 It randomizes it a bit more :D |
| ||
To further randomize, do more seedrnd millisecs() throughout the execution of your program. While millisecs() is a constant, the speed of your program is not. You will always hit subtle variations in texture loading time, scene rendering time, disk accessing time, depending on system load/virtual memory usage/a thousand other things, etc. Inserting more seedrnd millisecs() at intervals will further randomise the sequence of events. Even if the first seedrnd HAPPENS to come up with the same number it did last time, the second one is unlikely to, so no matter what, you'll keep getting random events occuring. It's best to put the seedrnd millisecs() after a loading period, say - level loading, as this is the time when milliseconds of difference in execution are most likely to have occured. +BlackD |