The Daily Click ::. Forums ::. Non-Klik Coding Help ::. Random Numbers?
 

Post Reply  Post Oekaki 
 

Posted By Message

Dave Matthew (Jester Gaming)



Registered
  09/07/2004
Points
  148
15th May, 2005 at 06:38:08 -

Hi!
I were just wondering... how does a computer compute a random number? that seems impossible to me.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
15th May, 2005 at 06:57:12 -

A common approach is to use the internal system clock and perform an unlikely function on it - because it's constantly changing, this gives the appearance of true randomness. Another approach is to use a random seed number, which always generates the same sequence of numbers (possible using the MMF "Randomize" action).

You're right that it is impossible for a computer to generate true random numbers, because the whole point of computers is that they're entirely deterministic and predictable. The only way to get a computer to generate a truly random number is to use some external input as a source - one method I read about was using the distance the mouse has moved as a seed. www.random.org goes so far as to use radio noise to generate a random number.

Image Edited by the Author.

 
http://www.davidn.co.nr - Games, music, living in America

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
15th May, 2005 at 07:37:31 -

I believe they use radioactive sources for random numbers too - or leave the lens cap on a webcam (same idea as radio waves).


The time is usually the seed for the random function. They're designed to give large changes in output with small increments in seed in order to appear more random (because time constantly increments). If you really want to know download the source for the Mersenne Twister algorithm - not used by C or most languages, but it is built into PHP, and infinitely better than the default functions.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
15th May, 2005 at 08:16:08 -

One way the random seed is picked is sometimes when you open a game and there is a "press start" menu. The time between the start of the app and when you press start is the seed.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
15th May, 2005 at 10:06:21 -

I've seen the Mersenne Twister used to awesome effect in a few games written in D, so that comes highly recommended.

Now that would be a brilliant idea for an extension.

 
n/a

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
15th May, 2005 at 10:15:10 -

What, a Mersenne Twister extension? Somebody should make one, they'd be the most awesomest guy in Click.

 
n/a

Pete Nattress

Cheesy Bits img src/uploads/sccheesegif

Registered
  23/09/2002
Points
  4811
15th May, 2005 at 11:11:26 -

Yeah, someone did, but he was a wanker.

 
www.thenatflap.co.uk

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
15th May, 2005 at 12:48:59 -

I thought that was the guy who made all those poodle games and ranted about all the crap in life?

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
15th May, 2005 at 14:04:59 -

since we're talking physics, isn't the entire universe deterministic? That means that nothing in the universe can be random. What a pain.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
15th May, 2005 at 14:27:26 -

even we aren't randomistic, every thought you think is just an electric pulse that goes through you brain and stuff. Urrrghh.... it feels crap to be so predictable

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
15th May, 2005 at 14:29:09 -

I don't know where you're getting that from. The behaviour of any particle is random within a certain probablity spread (well, actually they can do anything but the probability is asymptotic outside what's likely). So everything is random on a subatomic scale.

Sort of.

 
n/a

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
15th May, 2005 at 15:04:04 -

I forgot what caused radiation, but isn't that random?

and, er, when you get a degree in particle physics, make us a massive universe to store information about every particle in the universe so we can make time machines and shit

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
16th May, 2005 at 14:15:19 -

Only according to quantum mechanics is particle behavior random (radiation is just photons so according to quantum mechanics that's random too).

 
Resize! - www.clicksplat.com/comparison.html

Nuklear41

Possibly Insane

Registered
  12/01/2008
Points
  2395

VIP MemberPS3 OwnerWii Owner
21st May, 2005 at 16:43:17 -

I made a totally random thing. It is called........nevermind. Great game though.

 
Image

Joachim



Registered
  29/06/2005
Points
  6
22nd July, 2005 at 08:47:36 -

If you're wondering how to get a random number in one of your games, I know how (MMF)
I you want to have a random number between 1-10 do like this... You have a counter and for example "at start of frame" set counter to 10 - random (10). And the counter is set to 10 minus a random number between 1-10.

 
Knowledge; the way to succesion.
   

Post Reply



 



Advertisement

Worth A Click