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

#1 2011-11-19 12:40:56

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Random chance percentage

How would I make something happen by a random chance of (variable)?


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#2 2011-11-19 12:48:01

nickbrickmaster
Scratcher
Registered: 2010-02-02
Posts: 500+

Re: Random chance percentage

use the
[blocks]<<pick random( 1 )to( 10 )> [/blocks]
block.

Last edited by nickbrickmaster (2011-11-19 12:49:47)


Ask me what I'm doing, wait an hour than roll a die, if it's 4-6, I'm playing Skyrim, if it's 1, I'm eating, if it's 2-3 I'm programming.
Steam: nickbrickmaster | RotMG: PwnThemAll | Minecraft: nickbrickmaster | League Of Legends: BaneOfTitans

Offline

 

#3 2011-11-19 12:56:05

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Random chance percentage

nickbrickmaster wrote:

use the
[blocks]<<pick random( 1 )to( 10 )> [/blocks]
block.

Ik, but how would I do it?

What would the full script be, say i wanted it to ask whats your name then a random variable% chance it would say thats a good name. ?


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#4 2011-11-19 13:14:26

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Random chance percentage

Pecola1 wrote:

nickbrickmaster wrote:

use the
[blocks]<<pick random( 1 )to( 10 )> [/blocks]
block.

Ik, but how would I do it?

What would the full script be, say i wanted it to ask whats your name then a random variable% chance it would say thats a good name. ?

Say you wanted the chance to be 3/5, you would put:

Set 'variable' to pick random 1-5        (first number's always one, second number is the denominator of the chance)
If 'variable'=1 or 'variable'=2 or 'variable'=3        (keep going up until you reach the numerator of the chance)
Script here
Else
Other script here

If you want it to be clearer, tell me and I'll upload the scripts in a project.

By the way, the numerator is the top number in a fraction, denominator is bottom. So in my example, the numerator is 3, and the denominator is 5.  smile


Why

Offline

 

#5 2011-11-19 13:31:08

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Random chance percentage

RedRocker227 wrote:

Pecola1 wrote:

nickbrickmaster wrote:

use the
[blocks]<<pick random( 1 )to( 10 )> [/blocks]
block.

Ik, but how would I do it?

What would the full script be, say i wanted it to ask whats your name then a random variable% chance it would say thats a good name. ?

Say you wanted the chance to be 3/5, you would put:

Set 'variable' to pick random 1-5        (first number's always one, second number is the denominator of the chance)
If 'variable'=1 or 'variable'=2 or 'variable'=3        (keep going up until you reach the numerator of the chance)
Script here
Else
Other script here

If you want it to be clearer, tell me and I'll upload the scripts in a project.

By the way, the numerator is the top number in a fraction, denominator is bottom. So in my example, the numerator is 3, and the denominator is 5.  smile

That might help then all I need is to make the fraction  a percentage (easy)
Please upload!


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#6 2011-11-19 14:12:04

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Random chance percentage

Pecola1 wrote:

RedRocker227 wrote:

Pecola1 wrote:


Ik, but how would I do it?

What would the full script be, say i wanted it to ask whats your name then a random variable% chance it would say thats a good name. ?

Say you wanted the chance to be 3/5, you would put:

Set 'variable' to pick random 1-5        (first number's always one, second number is the denominator of the chance)
If 'variable'=1 or 'variable'=2 or 'variable'=3        (keep going up until you reach the numerator of the chance)
Script here
Else
Other script here

If you want it to be clearer, tell me and I'll upload the scripts in a project.

By the way, the numerator is the top number in a fraction, denominator is bottom. So in my example, the numerator is 3, and the denominator is 5.  smile

That might help then all I need is to make the fraction  a percentage (easy)
Please upload!

Okay, I've made a project that should help you. Download it and you'll see notes explaining each part of the scripts.
http://scratch.mit.edu/projects/RedRocker227/2159971


Why

Offline

 

#7 2011-11-19 14:51:07

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Random chance percentage

Pecola1 wrote:

RedRocker227 wrote:

Pecola1 wrote:


Ik, but how would I do it?

What would the full script be, say i wanted it to ask whats your name then a random variable% chance it would say thats a good name. ?

Say you wanted the chance to be 3/5, you would put:

Set 'variable' to pick random 1-5        (first number's always one, second number is the denominator of the chance)
If 'variable'=1 or 'variable'=2 or 'variable'=3        (keep going up until you reach the numerator of the chance)
Script here
Else
Other script here

If you want it to be clearer, tell me and I'll upload the scripts in a project.

By the way, the numerator is the top number in a fraction, denominator is bottom. So in my example, the numerator is 3, and the denominator is 5.  smile

That might help then all I need is to make the fraction  a percentage (easy)
Please upload!

If you want it to take less time than if variable = 1, 2, 3 etc. You can use something like this:

If variable > 0 and variable < 4

Offline

 

#8 2011-11-19 15:38:54

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Random chance percentage

ImagineIt wrote:

Pecola1 wrote:

RedRocker227 wrote:


Say you wanted the chance to be 3/5, you would put:

Set 'variable' to pick random 1-5        (first number's always one, second number is the denominator of the chance)
If 'variable'=1 or 'variable'=2 or 'variable'=3        (keep going up until you reach the numerator of the chance)
Script here
Else
Other script here

If you want it to be clearer, tell me and I'll upload the scripts in a project.

By the way, the numerator is the top number in a fraction, denominator is bottom. So in my example, the numerator is 3, and the denominator is 5.  smile

That might help then all I need is to make the fraction  a percentage (easy)
Please upload!

If you want it to take less time than if variable = 1, 2, 3 etc. You can use something like this:

If variable > 0 and variable < 4

Oh yeah, I can't believe I didn't realise that! Thanks!  big_smile


Why

Offline

 

#9 2011-11-19 16:03:38

rabbit1131
Scratcher
Registered: 2009-10-16
Posts: 1000+

Re: Random chance percentage

http://i41.tinypic.com/6htkas.png


The Intergalactic Adventures of Revesilia! I hope you will partake in this gigantic undertaking, to build the sequel to the hit map The Adventures of Revesilia! The Intergalactic Adventures of Revesilia Map Builders Application thread! http://internetometer.com/image/35004.png

Offline

 

#10 2011-11-19 16:37:11

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Random chance percentage

For something more advanced, it might also be a good idea to store results. You don't want to contradict yourself after one second!  tongue

Offline

 

#11 2011-11-20 19:00:13

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Random chance percentage

No, what I want is for it to ask, "what percentage"
"whats your name"
then if the randomness of answer1 % it will say Yes for 2 secs


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#12 2011-11-20 19:03:53

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Random chance percentage

LS97 wrote:

For something more advanced, it might also be a good idea to store results. You don't want to contradict yourself after one second!  tongue

Like bingo.  tongue


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#13 2011-11-22 11:16:31

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Random chance percentage

I really want this guys! HelP!


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

Board footer