Author Topic: Randomness  (Read 930 times)

S.

  • Hero Member
  • *****
  • Posts: 1621
    • View Profile
Randomness
« on: July 14, 2010, 05:56:49 pm »
This phenomenon has stunned me forever.

How do computers calculate random numbers?

If a game calculates random numbers, and I save 1 sec before it generates that number. After saving, I find out that the number generated is 5. Next thing I do is load that savegame. Will the number be 5 again? Or will it be something else?


Credit to blue_h3x for the new avatar. Glossary
[/size]

Mincus

  • Hero Member
  • *****
  • Posts: 2433
    • View Profile
Re: Randomness
« Reply #1 on: July 14, 2010, 06:12:26 pm »
Short answer: They don't, they use some clever maths and usually the system uptime or system clock to make it seem random.

Long answer is probably better served by Wikipedia: http://en.wikipedia.org/wiki/Random_number_generation#Computational_methods
I also suggest checking the pseudo random number generator page for more info: http://en.wikipedia.org/wiki/Pseudo-random_number_generator

S.

  • Hero Member
  • *****
  • Posts: 1621
    • View Profile
Re: Randomness
« Reply #2 on: July 15, 2010, 04:35:17 am »
So in theory, randomness does not exist?
Credit to blue_h3x for the new avatar. Glossary
[/size]

blue_h3x

  • Hero Member
  • *****
  • Posts: 4732
    • View Profile
    • AS Tournament
Re: Randomness
« Reply #3 on: July 15, 2010, 04:39:19 am »
So in theory, randomness does not exist?

You could argue either. In the endlessness of space you could say things are random, though likewise you could argue that things happen due to the spin of electrons, which follow the laws of quantum mechanics.

Random number generators always give out the same list of numbers, and to make them look random, you use a 'seed'. This seed is mostly the time in milliseconds, which makes the numbers seem random.
Austria is just like Yorkshire, but they have bigger hills.... oh and they have real snow too

Hammer

  • Sr. Member
  • ****
  • Posts: 301
  • ¯\_(ツ)_/¯
    • View Profile
Re: Randomness
« Reply #4 on: July 15, 2010, 08:56:33 am »
Pseudo-random is pretty much how it is done.

http://en.wikipedia.org/wiki/Mersenne_twister is probably a good example of one of the methods used.

Hardware side, you can make ring oscillators that may be close enough (note that depending on how you build them, there will be deficiencies) to what you would need.

| Hammer[BAN] | Youtube Page | Hammer[TIME] |
Currently playing: Starcraft II, Audiosurf

Mincus

  • Hero Member
  • *****
  • Posts: 2433
    • View Profile
Re: Randomness
« Reply #5 on: July 15, 2010, 09:19:48 am »
So in theory, randomness does not exist?

Not in your standard computer system without specialist hardware.
Whether it exists in the universe as a whole is more a philosophical question than a technical one. ;)

Laserrobotics

  • Robot Overlord
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3484
  • Beep boop everyone.
    • View Profile
    • Steam ID
Re: Randomness
« Reply #6 on: July 15, 2010, 11:57:28 am »
2 questions:
1) How would a ring oscillator help with an RNG, being as it can only be true or false and
2) What specialist hardware could possibly get around the fact that you're procedurally generating something that's supposed to be random?
Note to self:  1/24/12 Awawayabeft

Hammer

  • Sr. Member
  • ****
  • Posts: 301
  • ¯\_(ツ)_/¯
    • View Profile
Re: Randomness
« Reply #7 on: July 15, 2010, 01:01:42 pm »
2 questions:
1) How would a ring oscillator help with an RNG, being as it can only be true or false and

The key is you don't build just one oscillator circuit - you run a few of them and there are a few ways you get readings out of them, and the key part of the ring oscillator circuit is that you are intentionally supposed to exploit the metastable state in between true/false.

After you take into account that that you need a few of them, you can then XOR the ring oscillator inputs and then sample the results in a flip flop. This is just one example though.
« Last Edit: July 15, 2010, 01:08:05 pm by Hammer »
| Hammer[BAN] | Youtube Page | Hammer[TIME] |
Currently playing: Starcraft II, Audiosurf

Passerby

  • Hero Member
  • *****
  • Posts: 1534
    • View Profile
Re: Randomness
« Reply #8 on: July 15, 2010, 02:20:34 pm »
love this community it is one of the few places where people would actually think about this and try to answer it and prolly the olny gaming community that would.

Uupis

  • Sr. Member
  • ****
  • Posts: 449
    • View Profile
Re: Randomness
« Reply #9 on: July 16, 2010, 04:09:25 am »
Indeed.

S.

  • Hero Member
  • *****
  • Posts: 1621
    • View Profile
Re: Randomness
« Reply #10 on: July 16, 2010, 05:35:13 am »
2 questions:
1) How would a ring oscillator help with an RNG, being as it can only be true or false and

The key is you don't build just one oscillator circuit - you run a few of them and there are a few ways you get readings out of them, and the key part of the ring oscillator circuit is that you are intentionally supposed to exploit the metastable state in between true/false.

After you take into account that that you need a few of them, you can then XOR the ring oscillator inputs and then sample the results in a flip flop. This is just one example though.

But no matter how complicated the proces, it can never be 100% random, or am I wrong?
Credit to blue_h3x for the new avatar. Glossary
[/size]

chimaeraUndying

  • Hero Member
  • *****
  • Posts: 821
  • MADNESS
    • View Profile
Re: Randomness
« Reply #11 on: July 16, 2010, 05:50:39 am »
I know that things like atmospheric noise and the half-lives of certain elements are considered "True Random" and used when a random input is needed for scientific tests.

But no matter how complicated the process, it can never be 100% random, or am I wrong?

That's more of a theological or philosophical debate, I think.

S.

  • Hero Member
  • *****
  • Posts: 1621
    • View Profile
Re: Randomness
« Reply #12 on: July 16, 2010, 06:10:45 am »
I know that things like atmospheric noise and the half-lives of certain elements are considered "True Random" and used when a random input is needed for scientific tests.
Hey, that's pretty interesting!
Credit to blue_h3x for the new avatar. Glossary
[/size]

Oopla

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: Randomness
« Reply #13 on: July 16, 2010, 06:36:55 am »
I know that things like atmospheric noise and the half-lives of certain elements are considered "True Random" and used when a random input is needed for scientific tests.

But no matter how complicated the process, it can never be 100% random, or am I wrong?

That's more of a theological or philosophical debate, I think.

Yup www.random.org and if you click on the "Introduction" link there's a long explaination that I didn't read.
My channels:
Streaming  http://www.justin.tv/oopla
Youtube     http://www.youtube.com/Mougnu

Laserrobotics

  • Robot Overlord
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3484
  • Beep boop everyone.
    • View Profile
    • Steam ID
Re: Randomness
« Reply #14 on: July 16, 2010, 01:20:31 pm »
On the topic of ring oscillators, one of my friends was messing around with redstone dust in Minecraft and found out that you can make them with some creative use of NOT torches.  Cue him attaching doors to every possible spot on the circuit, leading to all of them alternating between open and closed constantly.

With a bit of thinking, you could probably get a random number generator running using lots of dust, doors, and possibly some levers.
Note to self:  1/24/12 Awawayabeft