Aces High Bulletin Board

General Forums => The O' Club => Topic started by: eskimo2 on February 02, 2003, 08:36:09 AM

Title: Question for old time computer programers:
Post by: eskimo2 on February 02, 2003, 08:36:09 AM
How do programs produce random numbers?

I was playing solitare on the computer for the first time ever yesterday.  Thinking about the avility to random shuffle gave me a flashback to high school computer class in 1983...  We were writing simple graphic programs and I remember messing around with the computers ability to pick a random number out of any set of numbers.

As I look back on this, it seems to me now that that must be a very unnatural thing for a computer to do... to choose something without a pattern, cause, or reason.  Computers work on logic and math.  How do you use logic and math to create a whim?

So what is the math theory behind having a computer pick a random number?

Thanks,

eskimo
Title: Question for old time computer programers:
Post by: ra on February 02, 2003, 09:18:03 AM
There is no easy answer, but you are right, it is doubtful that a computer program can produce truly random numbers.  I've heard that there is a kind of hardware which contains a radioactive isotope.  The hardware detects the radioactive decay and somehow converts the information into a continuous stream of digits, which is then used by a computer for random numbers.

ra
Title: Question for old time computer programers:
Post by: Swoop on February 02, 2003, 09:19:47 AM
Algorithm using cpu clock as a random number seed.

(http://image1ex.villagephotos.com/extern/640697.jpg)
Title: Question for old time computer programers:
Post by: bounder on February 02, 2003, 09:24:13 AM
There is a site on the web that uses a CCD and a lava lamp to generate random numbers for use in computers, but whether they are truly random is doubtful.

Otherwise computers tend to use lists of pregenerated number I think.
Title: Question for old time computer programers:
Post by: eskimo2 on February 02, 2003, 09:41:10 AM
Quote
Originally posted by bounder
There is a site on the web that uses a CCD and a lava lamp to generate random numbers for use in computers, but whether they are truly random is doubtful.

Otherwise computers tend to use lists of pregenerated number I think.


So if you had 2 identical PCs, with the same OS, and the same card game, all brand new - each had never run the random program yet, they would deal the same cards on the same game when run for the first time?

eskimo
Title: Question for old time computer programers:
Post by: the_hegemon on February 02, 2003, 10:41:17 AM
Quote
Originally posted by bounder
Otherwise computers tend to use lists of pregenerated number I think.



Computers tend to use functions seeded with the CPU clock or some other information that changes frequently, as Swoop stated.  However, the results are only pseudo-random, and not truly random.


darkstar
Title: Question for old time computer programers:
Post by: eskimo2 on February 02, 2003, 11:08:53 AM
Quote
Originally posted by the_hegemon
Computers tend to use functions seeded with the CPU clock or some other information that changes frequently, as Swoop stated.  However, the results are only pseudo-random, and not truly random.


darkstar


Can you explain further?

eskimo
Title: Question for old time computer programers:
Post by: Skuzzy on February 02, 2003, 11:54:30 AM
The numbers are not random actually.  If you run long enough a pattern will emerge.

And yes,..if you took two computers, and seeded the random number generator (most modern computers have hardware that does this) with the same value, the pattern of numbers would match.

In a computer, random numbers never occur.  The idea behind the random number is to produce a set of numbers which appear to have no pattern to a person.
Title: Question for old time computer programers:
Post by: hardcase2 on February 02, 2003, 12:25:54 PM
and old method for rolling dice was a number generator that created a number from .00000001 to .99999999 and then multiplying that number by 6 then rounding up or down to the interger.
Title: Question for old time computer programers:
Post by: AKIron on February 02, 2003, 12:44:08 PM
Is this the beginning of another "free will" debate? ;)
Title: Question for old time computer programers:
Post by: Arlo on February 02, 2003, 12:52:20 PM
Doesn't appear to be.
Title: Question for old time computer programers:
Post by: AKIron on February 02, 2003, 01:11:06 PM
hehe, was joking.

Like Suzzy suggested, it's just matter of perspective.
Title: Question for old time computer programers:
Post by: john9001 on February 02, 2003, 01:58:22 PM
Quote
Originally posted by Swoop
Algorithm using cpu clock as a random number seed.

(http://image1ex.villagephotos.com/extern/640697.jpg)


swoop is right , at least as far as BASIC programs go, i used to write programs to generate ramdom lotto numbers.

the "randomness" occures when i would hit a key, the random sub-program would not grab the CPU clock until it got the "keypress"

BASIC  had a command for the ramdom function , but you had to write the programing to set the parimiters for the numbers you wanted , IE: seven different numbers & print,  etc

44MAG

"ramdom?? , god, i spell worse than HT
Title: Question for old time computer programers:
Post by: Tuomio on February 02, 2003, 04:07:52 PM
For my understanding, only random thing in the world is decaying of atom. Google for Schrodingers Cat, its simple "theory" of this process, even i can understand it..=)

Computers random is, like Skuzzy said, an algorithm, that picks one of its variables from computer clock. The randomness follows a bezier curve, but isnt apparent if your sampling rate isnt exactly evenly spaced. Ie enter press per every second hardly is exact enough to bring up this pheomenon..:) God knows how many different states a computer clock can have in one second, but i think its somehow related to the MHZ of your CPU.

I have only faint memory of this issue in my mind and i might be totally off the base here. So, forget what i said and do a websearch..:D
Title: Question for old time computer programers:
Post by: AKIron on February 02, 2003, 06:31:44 PM
Being in the computer and network support business I've seen folks prove that PCs are capable of randomness. At least that's how it seems when they want me to find that file they just saved. ;)
Title: Question for old time computer programers:
Post by: Angus on February 03, 2003, 06:57:26 AM
I used to write games in Basic so I know this a bit.
The RND function was based on a certain CPU seed, that is true. There was a RANDOMIZE (number) command to control where the seed would start. If you would for instance write a program like this:

10 RANDOMIZE 1277
20 FOR F = 1 TO 10
30 PRINT RND
40 NEXT F

no matter how often you ran this, you would always get the same sequence of numbers.
The function is not truly random, the RND has some rhythm in it.

However, since most game programs are constantly looping, and are very much based on player reactions, there is a way to scramble this a bit. Just let the program select a random number for every loop while the player is for instance, idle. Making it simple, the above program could be like this:

10 RANDOMIZE 1277
20 FOR F = 1 TO 10
25 LET X = RND. IF INKEY$ <> " " THEN GO TO 25
30 PRINT RND
40 NEXT F

This leaves the initiative by the user, he will have to press the space bar to get his random number, and will due to the computer's speed in relation to human reflection, never get the same row of numbers.....

Quite interesting.
Title: Question for old time computer programers:
Post by: Saintaw on February 03, 2003, 07:32:57 AM
radioactive Decay Random Nrs page (http://www.fourmilab.ch/hotbits/generate.html)

I need to add that (In web programming) I haven't realy met a criteria where you need an absolute random yet. So far using a combination of 16 characters can get you a lonnnnnnnnnng way before you find two who match up.