Conversation
Notices
-
how do you tell a computer to do something randomly?
Friday, 23-May-14 13:58:19 UTC from web-
@mushi You underpay a coder to write a script and remake it five times trying to get rid of all the bugs.
Friday, 23-May-14 14:20:48 UTC from web -
@mushi =rand()
Friday, 23-May-14 14:34:51 UTC from web-
@cinnamonswirl but what mechanism does it use to do a thing randomly? ( i think that doubt only makes sens to me)
Friday, 23-May-14 15:03:22 UTC from web-
@mushi Computers actually can't do things randomly on their own. Modern systems tend to use either: a "psuedorandom" number generator, which produces not truly random, but still highly difficult to reproduce values, or they build up what they call an "Entropy Cache", by sampling user mouse and keyboard entries, and in some cases, sampling user created files (Usually things like temporary internet files are used as "seeds"). The third method, used by organisations with a requirement for reliable "true" randomness involves the installation of a "hardware randomness generator" or "Entropy card". Most use radioactive decay to generate random noise, but some use radio receivers to tap into universal background radiation to achieve the same.
Friday, 23-May-14 15:23:10 UTC from web-
@cinnamonswirl well, that is pretty complex, but answered my question. thank you ^^
Friday, 23-May-14 15:33:24 UTC from web -
@cinnamonswirl oh cool!
Friday, 23-May-14 15:40:54 UTC from web -
@cinnamonswirl DO you know whether I'm wrong about it sometimes being based on the processor clock? I thought I heard that somewhere, but I don't know how it would even work.
Friday, 23-May-14 15:42:03 UTC from web-
@pony Not for most cases. For the average computer program, the pRNG seed is initialized to some value (often the computer time), and calls to rand() and similar functions will perform some sort of math on the seed and return that value. A game I've poked at the source for has a custom pRNG system (because it needs to sync across netgames) that demonstrates the concept. Basically, if srand() is called with the same value, successive calls to rand() will return the same sequence of values.
That said, clock drift can be used for randomness. It's usually pretty slow, however, so it's better to use one of the methods Cinnamon mentioned, or if desired use clock drift to seed a pRNG.Friday, 23-May-14 16:24:45 UTC from web
-
-
-
@mushi As I understand, random can be based on the processor's clock which is controlled by a quartz crystal. Corrections anybody?
Friday, 23-May-14 15:39:47 UTC from web-
@pony cerulean gave me a cool aswer
Friday, 23-May-14 15:41:35 UTC from web
-
-
-
-