This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-19 00:40:22

dingdong
Scratcher
Registered: 2007-08-09
Posts: 1000+

how do you code random?

this has always puzzled me, how was the bit for random selection code bits ever made, everything started with binary which is just 1 and 0 and that doesn't give you anything for random selection, so how the heck do you get some randomly select a number or something?


http://img851.imageshack.us/img851/2829/superanbanner.png
click the image for my music

Offline

 

#2 2010-07-19 00:47:33

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: how do you code random?

...


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#3 2010-07-19 01:45:30

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: how do you code random?

It's never truly a random number.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#4 2010-07-19 01:46:54

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: how do you code random?

Sunrise-Moon wrote:

It's never truly a random number.

^^ Right you are! Also, I think this belongs in All About Scratch, or Advanced Topics... hmmm... whatever, I'll move it to Advanced Topics. >.>


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#5 2010-07-19 01:49:46

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: how do you code random?

MyRedNeptune wrote:

Sunrise-Moon wrote:

It's never truly a random number.

^^ Right you are! Also, I think this belongs in All About Scratch, or Advanced Topics... hmmm... whatever, I'll move it to Advanced Topics. >.>

It's not really about Scratch though  tongue .


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#6 2010-07-19 01:55:33

what-the
Scratcher
Registered: 2009-10-04
Posts: 1000+

Re: how do you code random?

If you look at vb.net the random numbers produced on that are the same every time you run it.

Maybe some random numbers are made by the computer sensing whether or not the network is busy.

If network busy
set random to 1

else
wait n seconds

If network busy
set random to 2

else
wait n seconds

If network busy
set random to 3

else
(ect)


http://imageshack.us/m/64/9034/ddfss.pngMy site
Find someone post count. Click posts under username. Find number of pages. Times that by 40 for min and 60 for max and you have a rough estimate of post count.

Offline

 

#7 2010-07-19 01:58:57

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: how do you code random?

Perhaps it's like a spinner that is continuously turning until it is told to stop.

Last edited by Sunrise-Moon (2010-07-19 01:59:06)


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#8 2010-07-19 02:12:09

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: how do you code random?

I believe that random numbers in things like microhips and scratch are just a long list of numbers that do eventually loop back to the start. This is called Pseudo random. Other things, such as computers, can calculate random numbers by using changing variables to affect the outcome of the number, e.g. the time, the date, the current processing speed, the number of files in a folder, how many times you have clicked the mouse etc, and while this is still not random as it is calculated, it will not loop. a good one for random number generation would be the digits in pi. if you can get them to their current calculated length, you will find they go on for a VERY long time and no repretiton has yet been found. True random, however, cannot really be achieved by machines, no (I believe) by humans as our descisions and thoughts are directly affected by our mood, the enviroment, our personality and previous experience, making any random choice of ours actually decided and not random at all  tongue


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#9 2010-07-19 13:29:09

MasterOfDeception
Scratcher
Registered: 2009-12-29
Posts: 100+

Re: how do you code random?

Yeah the numbers aren't truly random, computers use algorithms like this to make random numbers.


"My Language Arts teacher beat Chuck Norris up." -12three

Offline

 

#10 2010-07-19 18:25:29

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: how do you code random?

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

Squeak uses the current time in milliseconds to seed its random numbers.

Last edited by nXIII (2010-07-19 18:26:02)


nXIII

Offline

 

#11 2010-07-19 18:49:11

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: how do you code random?

nXIII wrote:

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

Squeak uses the current time in milliseconds to seed its random numbers.

Well, Scratch's random block isn't exactly the best.....


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#12 2010-07-19 19:40:11

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: how do you code random?

ScratchReallyROCKS wrote:

nXIII wrote:

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

Squeak uses the current time in milliseconds to seed its random numbers.

Well, Scratch's random block isn't exactly the best.....

I was just telling people that Squeak uses the time to seed random numbers. Those two paragraphs have nothing to do with each other.


nXIII

Offline

 

#13 2010-07-19 20:19:39

vortex19
Scratcher
Registered: 2009-06-03
Posts: 100+

Re: how do you code random?

nXIII wrote:

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

Squeak uses the current time in milliseconds to seed its random numbers.

I believe it is atmospheric noise (at least that's what random.org does).

Offline

 

#14 2010-08-05 13:18:01

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: how do you code random?

nXIII wrote:

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

I'm pretty sure that it is something like the frequency that any atom is vibrating at... Or something like that.  hmm


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#15 2010-08-05 19:16:26

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: how do you code random?

Jwosty wrote:

nXIII wrote:

Someone needs to point out that you can use a real-world phenomenon to generate 100% random numbers. I just forget what it is....

I'm pretty sure that it is something like the frequency that any atom is vibrating at... Or something like that.  hmm

Yea, that sounds right. I think it's the random motion of atoms.


nXIII

Offline

 

Board footer