Page 1 of 1

better randomness

Posted: Wed Dec 30, 2009 5:23 am
by y offs et
I refer you to this page -

http://www.delphibasics.co.uk/RTL.asp?Name=Random

"Delphi uses a pseudo random number generator ..."

The use of system time as a seed is used in other languages also, and works well as long as the application is not generated automatically at a preset time.

I request a "Randomize" type function, or, probably easier, a way to access system time.

Now before you say "personality" check the enclosed demo.

-------------------------------

I have thought of another way that would work for what I am doing. I could have a read-in text file with a value to use as a seed, and on program closing, write-out the value plus one, so next start the seed would be different.

Posted: Wed Dec 30, 2009 7:06 am
by VilleK
I see the problem, personality becomes the same every time. Inside the editor it is a new value on each run. In a game you would have a title-screen that required a keypress and if that title-screen also made use of the random-function then the game would use different random values because the user won't press the key at exactly the same time.

We could add a getSystemTime() function to scripting, this can be useful for other things as well.

Posted: Wed Dec 30, 2009 2:52 pm
by y offs et
In format of number of seconds from mid night should suffice for randomness. For other uses, I don't know.

Posted: Wed Dec 30, 2009 3:36 pm
by jph_wacheski
A getSystemTime() would be usefull for various things, please do. .

I was sorta suprised at first, when I started making games, at how difficult it is to get a computer to generate random numbers. I just go with Villes suggestion of a human intervention in a loop to generate random starting positons in the generator,. slight timeing differences seem to suffice,. . the whole psudo-randomness turns out to be a great thing for procedurals though,. from graphics, to mazes,. and wave formations,. getting the same 'random' pattern is very usefull actually.

attached is a little expansion of the above example,.