quick question on seedRnd millisecs()

Blitz3D Forums/Blitz3D Beginners Area/quick question on seedRnd millisecs()

GameCoder(Posted 2004) [#1]
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


GfK(Posted 2004) [#2]
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.


GameCoder(Posted 2004) [#3]
Thats random enough for me.

Thx GFK :)


wizzlefish(Posted 2004) [#4]
I would do something of this sort:

SeedRnd (Millisecs() + Pi) * Pi / Pi - Millisecs() + 5.66678321


It randomizes it a bit more :D


GfK(Posted 2004) [#5]
I would do something of this sort:

SeedRnd (Millisecs() + Pi) * Pi / Pi - Millisecs() + 5.66678321




It randomizes it a bit more :D
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().


BlackD(Posted 2004) [#6]
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