Block Request

I would like a percentage block that can give a percentage chance to a random chosen number from this block:

IMG_0422

It seems that every time I try to make a way to have a skin to not be picked from a pack all the time, because the skin I’d want to consider the hardest to get, practically always gets picked, ruining that whole point. All I’m asking for is a percentage block to change that.

You can do this yourself in Snap! code. I don't know what you want for the user interface (which is one reason why you should write it yourself!) but if I were doing it I'd take a list of values and weights as input, so

untitled script pic (10)

would report 7 or 8 or 1, but would be five times as likely to pick 8 as either of the others.

Code:

As a rule we try to avoid adding primitive blocks to Snap! that could just as well be written in Snap!. :~)

I made these block. They may help:
untitled script pic
Tamagotchi script pic

Thanks!

I’m not able to drag them into snap…

I was able to

I can drag the first one in but just not the second one for some reason? (Edit Never mind you just had to press and hold then drag.

What if a weight is non-integer?

What if a weight is non-integer?

I figured someone would ask that. :~) Then you just multiply all the weights by the same number, and round. If you're good at math, you program the block to scale the weights automatically.

oh, this is my block!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.