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.

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
22nd July, 2005 at 09:43:48 -

I think he meant how do computers actually calucate them, because computers run solely on the basis of linearity, so for one to calculate an actual random number would be impossible.

 
Image

Deleted User
22nd July, 2005 at 15:48:09 -

I just had to since you all yell at me about stuff like this

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

I were or i Was?

Image Edited by the Author.

 

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
22nd July, 2005 at 16:09:41 -

Depends where you're from. If he's from Yorkshire like me, then that'd be the correct grammar round here.

 
Image

Deleted User
22nd July, 2005 at 17:10:18 -

Oh ok.

 

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
23rd July, 2005 at 13:18:25 -

Well, that depends on how the Motherboard chooses to generate one. Mine counts the number of electron running through pin 1 or something. It's wierd.

 
Craps, I'm an old man!

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
1st August, 2005 at 06:13:14 -

I think there was this guy who made a 600,000 bits random bits CD-ROM with a formula he created which creates truly random bits without any of that help.

At least, that's what I read in my maths book.

 
Old member (~2004-2007).

Deleted User
2nd August, 2005 at 00:07:49 -

wow 3 moth old topic still runnin but i have no clue how it does it...

 

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
2nd August, 2005 at 05:49:52 -

Verrry slooowly.

 
Old member (~2004-2007).

Rei Ayanami



Registered
  27/07/2005
Points
  48
2nd August, 2005 at 06:49:31 -

@ That means that nothing in the universe can be random. What a pain.

Yeah, ofcourse randomness doesnt exist in real life.
Or... wait... Meh, forgot what i where thinking.

 
n/a

Matt Boothman

The Nissan Micra of forum members

Registered
  20/09/2002
Points
  109

Game of the Week Winner
2nd August, 2005 at 14:13:34 -

It's weird innit how you can change the history of the world. Like you could say "Hellog" instead of "Hello" and the Welsh would rule the world.

 
http://soundcloud.com/normbo - Listen to my music.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
3rd August, 2005 at 11:34:19 -

Or go 1 billion years back and fart, then all life would cease to exist except you, and you would die anyway of starvation.

 
.

vortex2



Registered
  27/05/2002
Points
  1406
3rd August, 2005 at 11:42:43 -

Yeah I just did that yesterday.

 
A bit of insanity with every bite!

Deleted User
4th August, 2005 at 21:50:10 -

heh...

 

Deleted User
4th August, 2005 at 21:52:23 -

wait i thought of the one and only random thing in the world Creatures

their ideas are random and their features are random

 

Deleted User
5th August, 2005 at 21:17:58 -

Oh yeh because there is limitations to human thought like you cant picture a color that youve never seen... i wonder if there are any.....just try to imagen one... I cant well mabey thats because im dumb

 

hop



Registered
  16/03/2005
Points
  916
5th August, 2005 at 23:34:38 -

Not really because there are limitations on human thought. It's because everything we do and think comes from an outside stimulus. Then you create other stimuli for yourself and other organisms to reply to. Every decision we make is basically pre-determined by our life experiences. We really have no choice in what we do in life. Nothing is truly random, everything is linier and there is only one possible future.

Unless there truly are minute particle we haven't discoved or don't understand whose movements are truly random.

I'm thinking too much.

 
Working On:
Psydude
Castle Wars(working title)

XBLGT: sunstrike9

Deleted User
6th August, 2005 at 00:10:03 -

Well thats whats fun thinking hard, well somtimes if its voentary. But I dont think there is only one future mabey there are many possibilitys but you will only thinkof doing like four different things in a situation then an infinuete ammount based on what you have seen and heard in you life so in my thoughts there is only a few billion different futures not 1 and not infinute but that probably didnt make any sence because when i try to explain my thought on somthing as complicated as the futer i usually dont make sence.

 

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
9th August, 2005 at 06:25:09 -

That random comment wasn't actually random, you know.

 
Old member (~2004-2007).

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
9th August, 2005 at 08:36:58 -

Perhaps one should give a definition of random, in order to make it useful for discussing.

Because things you know afterwards aren't so random anymore. But before, you couldn't predict what was going to happen.

O and for an easy implementation of random, just make a counter and make it loop (counter++) between your min and max value. And if you need a random number, just grab it.
Or use the Mersenne Twister.
Or create your own pseudo random generator.


 
Image jenswa.neocities.org

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
19th August, 2005 at 20:02:35 -

'Hoy... I didn't think this would merit it's own thread; curious as it is, it serves little purpose.
So I'm posting it here.

I made a little program in MMF that would take an overlay object, paint it black, then, on the press of a button, fast-loop-draw 64 pixels at (random(640),random(480) with color (random(256),random(256),random(256).
And after a while, this pattern developed:

Image

Curious, no?

 
Go Moon!

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
20th August, 2005 at 01:09:15 -

Fifth: something like that can be seen in the Mersenne Twister example. The Mersenne Twister object has a better randomizer.

<i."Unless there truly are minute particle we haven't discoved or don't understand whose movements are truly random."
Electrons move randomly in an atom.

 
http://www.klik-me.com

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
20th August, 2005 at 17:55:53 -

The same thing happens in the Fastloop example (the starfield) as well.

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

Deleted User
20th August, 2005 at 20:40:13 -

couldnt you just do and static movement choose all 32 directions as possible to look to at the start of the frame then the direction would be completely random right?

 

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
22nd August, 2005 at 08:10:56 -

Who said life was linear, was that just discovered and noone told me? As last I heard noone knows how to predict the movement of quantum forces, infact its very very chaotic. If fate exists, prove it.

Computers calculate 'random' numbers through various inputs. You're correct, computers aren't and most likely will never be random. Time, mouse, and various other inputs are used in calculation of 'random' numbers in a computer. If you aware of the input you can determine what number will be called, and it will no longer be random.

@Joachim: your
'10-random(10)'
example is the exact same as
'random(10)'

 
thinking is like pong, it's easy, but you miss sometimes.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
22nd August, 2005 at 08:17:49 -

Except that the range is 0 to 10 instead of -10 to 0.

 
Old member (~2004-2007).

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
22nd August, 2005 at 15:14:48 -

ummm, no....It would be 0-10 instead of 10-0...Don't talk, it hurts you.

 
thinking is like pong, it's easy, but you miss sometimes.

Muffin Batel [neonair games]



Registered
  09/08/2002
Points
  900
27th August, 2005 at 15:08:02 -

wont this topic die already?



 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
27th August, 2005 at 19:41:03 -

It's the thread that keeps on giving.

Image Edited by the Author.

 
thinking is like pong, it's easy, but you miss sometimes.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
1st September, 2005 at 06:48:33 -

Most programs create more random randomness by comparing the internal clock and the processor. Some of them have used user inputs like the distance the mouse has moved or keyboard stuff, but the pros don't like it as some people aren't very random when typing and using a non-essential piece of hardware means that you can't generate random numbers if say, the keyboard or mouse isn't working.

It's impossible to get truly random numbers. One book on cryptography I read has a section on unbiasing biased coins (in the digital sense). There's plenty of people and thousands of dollars invested in creating pure randomness. Some very high-security programs actually combine several sources of randomness, just to make sure that if a cryptohacker manages to plant a keygen in one of the sources, there's still the others to make it random.

Technically nothing is random in real life. Every random thing is about which subatomic particles bounce into which. But the thing is, we're unable to predict how such subatomic particles would act and that's what creates randomness. Now if someone could find a way to control subatomic particle movement, I could probably create some keygen to get passwords for high-security organisations .

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image
   

Post Reply



 



Advertisement

Worth A Click