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

#1 2009-11-22 05:11:24

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

What does Scratch use to pick random numbers?

Just curious.  smile


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#2 2009-11-22 06:04:30

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

Re: What does Scratch use to pick random numbers?

This would be interesting as visual basic (well microsofts visual basic) are the same random numbers every time on every computer that runs it.


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

 

#3 2009-11-22 07:19:09

UGWG
Scratcher
Registered: 2009-11-02
Posts: 40

Re: What does Scratch use to pick random numbers?

IF they did it JavaScript they use a simple script (of course they used an easier one in Java)
var x=Math.floor(Math.random()*99)                     and that would be 1 to 100.

Offline

 

#4 2009-11-22 11:41:02

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: What does Scratch use to pick random numbers?

I believe it uses some sort of algorithm, but I'm not sure what that algorithm is...


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#5 2009-11-22 12:22:29

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: What does Scratch use to pick random numbers?

Maybe it uses the id number of the program and does some random calculations to make it equal * , then it has 1 second to run through the numbers you listed and stop at the * number??


Hai.

Offline

 

#6 2009-11-22 21:29:51

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: What does Scratch use to pick random numbers?

One of the hardest things for people to program is a random number picker. It's usually done by creating a list, dividing, rounding, etc.. Another method is messing around with the time... what does Scratch use?


At least we should be glad that we have the random block.  smile


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#7 2009-11-22 23:27:24

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: What does Scratch use to pick random numbers?

It uses a variable gate dynamic oscillator that syncs the cpu load at a given moment with the speed fluctuation of a virtual cd-rom burning a bit-reduced copy of Judas Priest's Rocka Rolla. Then it multiplies (or divides) the result (and does abs if necessary) to derive the sweep range.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#8 2009-11-22 23:29:22

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: What does Scratch use to pick random numbers?

Really?


Hai.

Offline

 

#9 2009-11-22 23:42:23

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: What does Scratch use to pick random numbers?

Locomule wrote:

It uses a variable gate dynamic oscillator that syncs the cpu load at a given moment with the speed fluctuation of a virtual cd-rom burning a bit-reduced copy of Judas Priest's Rocka Rolla. Then it multiplies (or divides) the result (and does abs if necessary) to derive the sweep range.

Thanks!  smile


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#10 2009-11-23 15:30:14

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: What does Scratch use to pick random numbers?

Well whatever it is, it is not technically random. All of these methods people have suggested aren't random, they are just unpredictable.


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#11 2009-11-23 17:24:05

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: What does Scratch use to pick random numbers?

Without looking into the Scratch source code, but knowing a bit about computer generated random numbers (pseudo-random numbers), I would bet that Scratch uses a Linear Congruential random number generator.

More info here: http://en.wikipedia.org/wiki/Linear_congruential_generator

It is extremely fast, and if the coefficients c, m, and a are chosen properly it has a very large period and a very good distribution.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#12 2010-01-27 21:27:54

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

Re: What does Scratch use to pick random numbers?

fg123 wrote:

Maybe it uses the id number of the program and does some random calculations to make it equal * , then it has 1 second to run through the numbers you listed and stop at the * number??

That's not possible, because to make a random calculation it would have to use itself to generate the numbers for the calculation, but it couldn't. Do you see what I mean?


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

Offline

 

Board footer