Discuss Scratch

Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

Hey, I was wondering how to randomize costumes so that it will also broadcast something when that number is triggered. What I have so far is this.
whenIreceive In waterset fishtopickrandom1to1000iffish<700thenwaitpickrandom5to15secsswitchcostumeto Normal Fishbroadcast Caught Fishelseiffish<900thenwaitpickrandom5to10secsswitchcostumeto Bad Fishbroadcast Caught Fishelseiffish>900thenwaitpickrandom20to40secsswitchcostumeto Special fishbroadcast Caught Fish
But this isn't working. All help is appreciated.
gor-dee
Scratcher
1000+ posts

How do i randomize costumes?

Can you explain a bit more. do you want a different broadcast for each fish? When do you want the broadcast to happen?
Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

So I want it to broadcast “Caught Fish” so that it will show a shining ring around the caught fish. And I want it to happen when if the “Fish” variable is below say 700.

Last edited by Toasty_Boy (Jan. 28, 2017 21:49:04)

Bentton
Scratcher
53 posts

How do i randomize costumes?

whenIreceiveIn waterswitchcostumetopickrandom1to3waitpickrandomcostume#*2tocostume#*4secsbroadcastCaught fish
That should do!
Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

But I want it to be less common for certain costumes.
ShadowPheonixRPs
Scratcher
100+ posts

How do i randomize costumes?

Toasty_Boy wrote:

But I want it to be less common for certain costumes.
make duplicate costumes maybe? More of costume (a) then (b) and then (a) will appear more often.
Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

That might work, but I also want to make it efficient too. Thanks for the suggestion though.
ShadowPheonixRPs
Scratcher
100+ posts

How do i randomize costumes?

Toasty_Boy wrote:

That might work, but I also want to make it efficient too. Thanks for the suggestion though.
your welcome! I know its not the best way but it is the only way I can think of.
SBissay
Scratcher
500+ posts

How do i randomize costumes?

You could make a list with the combined probabilities of each costume.

Explanation : let's say you want costume 1 to be here 25% of the time, costume 2 : 30 %,costume 3 : 44% and costume 4 is the super shiny appearing 1% of the time.

Then, you'll have in your list : (25 ; 55 ; 99 ; 100).
(55 = 25 + 30; 99 = 25 + 30 + 44 ; 100 = 25 + 30 + 44 + 1)

From there, you just have to pick a random number between 1 and 100 and test which list item is higher than your random number :

setRandomVartopickrandom1to100setIndexto1setCostumeNumberto1repeatlengthofProbabiltyListifRandomVar>itemIndexoflistthensetCostumeNumbertoIndex+0changeIndexby1

Last edited by SBissay (Jan. 28, 2017 22:12:25)

asivi
Scratcher
1000+ posts

How do i randomize costumes?

Edited
Please share the project.

Last edited by asivi (Jan. 29, 2017 12:03:06)

Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

SBissay wrote:

You could make a list with the combined probabilities of each costume.

Explanation : let's say you want costume 1 to be here 25% of the time, costume 2 : 30 %,costume 3 : 44% and costume 4 is the super shiny appearing 1% of the time.

Then, you'll have in your list : (25 ; 55 ; 99 ; 100).
(55 = 25 + 30; 99 = 25 + 30 + 44 ; 100 = 25 + 30 + 44 + 1)

From there, you just have to pick a random number between 1 and 100 and test which list item is higher than your random number :

setRandomVartopickrandom1to100setIndexto1setCostumeNumberto1repeatlengthofProbabiltyListifRandomVar>itemIndexoflistthensetCostumeNumbertoIndex+0changeIndexby1
What is the “+ 0” there for.
deck26
Scratcher
1000+ posts

How do i randomize costumes?

Toasty_Boy wrote:

SBissay wrote:

You could make a list with the combined probabilities of each costume.

Explanation : let's say you want costume 1 to be here 25% of the time, costume 2 : 30 %,costume 3 : 44% and costume 4 is the super shiny appearing 1% of the time.

Then, you'll have in your list : (25 ; 55 ; 99 ; 100).
(55 = 25 + 30; 99 = 25 + 30 + 44 ; 100 = 25 + 30 + 44 + 1)

From there, you just have to pick a random number between 1 and 100 and test which list item is higher than your random number :

setRandomVartopickrandom1to100setIndexto1setCostumeNumberto1repeatlengthofProbabiltyListifRandomVar>itemIndexoflistthensetCostumeNumbertoIndex+0changeIndexby1
What is the “+ 0” there for.
It makes sure the value is treated as a number rather than text - it can make a difference.
SBissay
Scratcher
500+ posts

How do i randomize costumes?

It's a typo : it's
Index+1

The goal is to start with your first costume, and “upgrade” it if your random number is greater than the current list entry.

Last edited by SBissay (Jan. 28, 2017 22:36:37)

Toasty_Boy
Scratcher
100+ posts

How do i randomize costumes?

Toasty_Boy wrote:

SBissay wrote:

You could make a list with the combined probabilities of each costume.

Explanation : let's say you want costume 1 to be here 25% of the time, costume 2 : 30 %,costume 3 : 44% and costume 4 is the super shiny appearing 1% of the time.

Then, you'll have in your list : (25 ; 55 ; 99 ; 100).
(55 = 25 + 30; 99 = 25 + 30 + 44 ; 100 = 25 + 30 + 44 + 1)

From there, you just have to pick a random number between 1 and 100 and test which list item is higher than your random number :

setRandomVartopickrandom1to100setIndexto1setCostumeNumberto1repeatlengthofProbabiltyListifRandomVar>itemIndexoflistthensetCostumeNumbertoIndex+0changeIndexby1
What is the “+ 0” there for.
I don't think i'm up to that level yet in coding. I'm also not very familiar with lists yet, and how to use them in advanced code. But your help is very appreciated. Thank you.
SBissay
Scratcher
500+ posts

How do i randomize costumes?

Toasty_Boy wrote:

(snip)
I don't think i'm up to that level yet in coding. I'm also not very familiar with lists yet, and how to use them in advanced code. But your help is very appreciated. Thank you.

You're welcome ! Good luck with your project.
WookieeRoyale
Scratcher
9 posts

How do i randomize costumes?

Toasty_Boy wrote:

But I want it to be less common for certain costumes.
In that case, you probably have to use variables.
I've made a simple script here: https://scratch.mit.edu/projects/142407892/
asivi
Scratcher
1000+ posts

How do i randomize costumes?

Edited
Please share the project.

Last edited by asivi (Jan. 29, 2017 12:02:05)

Despicable_Dad
Scratcher
500+ posts

How do i randomize costumes?

Toasty_Boy wrote:

So I want it to broadcast “Caught Fish” so that it will show a shining ring around the caught fish. And I want it to happen when if the “Fish” variable is below say 700.

Remove the second and third broadcasts? (Am I missing something here?)
asivi
Scratcher
1000+ posts

How do i randomize costumes?

Despicable_Dad wrote:

Toasty_Boy wrote:

So I want it to broadcast “Caught Fish” so that it will show a shining ring around the caught fish. And I want it to happen when if the “Fish” variable is below say 700.

Remove the second and third broadcasts? (Am I missing something here?)
Perhaps the OP is broadcasting “in water” more than one time while waiting the random time it has.

@Toasty_Boy please share your project.

Last edited by asivi (Jan. 29, 2017 12:13:33)

Blue_Science
Scratcher
100+ posts

How do i randomize costumes?

I thins this would be adapted for you :

whenIreceive In waterifpickrandom1to100<50thenswitchcostumeto Normal Fishbroadcast Caught Fishelseifpickrandom1to100<50thenswitchcostumeto Bad Fishbroadcast Caught Fishelseif1=1thenswitchcostumeto Special fishbroadcast Caught Fishelse. . .Uh, 100% You'll say me ? Nope, it's just the remaining quarter :DSame 50%, but after the else block; so it's 25% of the total chancesSet the chance to catch this type of fish. Here, 50%

Powered by DjangoBB