How would I make something happen by a random chance of (variable)?
Offline
use the
[blocks]<<pick random( 1 )to( 10 )> [/blocks]
block.
Last edited by nickbrickmaster (2011-11-19 12:49:47)
Offline
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. ?
Offline
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.
Offline
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.![]()
That might help then all I need is to make the fraction a percentage (easy)
Please upload!
Offline
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.![]()
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
Offline
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.![]()
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
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.![]()
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!
Offline
Offline
For something more advanced, it might also be a good idea to store results. You don't want to contradict yourself after one second!
Offline
rabbit1131 wrote:
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
Offline
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!
![]()
Like bingo.
Offline
I really want this guys! HelP!
Offline