Discuss Scratch

LASERLEMONLIME123
New Scratcher
2 posts

RNG system

so I'm trying to make a RNG based game where you roll for rarer and rarer shapes. i need a script that is easy to add to that can randomly choose shapes using chances such as 1/2, 1/3, 1/4, 1/6, etc.
LASERLEMONLIME123
New Scratcher
2 posts

RNG system

i also need it to be alterable by a luck upgrade of sorts
CaliforniaCoders
Scratcher
100+ posts

RNG system

set [rng v] to (pick random (0) to (luck))
if <(rng) > [67]> then
say [Your Luck]
end
and just add more if loops
that-scrpbook-guy
Scratcher
3 posts

RNG system

Hi There LASERLEMONLIME123!
I have done a similar thing with a dice roll.
You can use part of the code if you want
Hope it was useful,
TSG
dem_bot
Scratcher
1000+ posts

RNG system

the problem with
(pick random (0) to (luck))
is that it only increases the chance to get the highest rarity item, while we want it to increase the chance for all rarer items.
I think the following system will be a bit better for that:
([10^ v] of (([log v] of (pick random (0.0) to (1.0))::operators) * ((1) / (luck)))::operators)
With luck always larger than 1.
Instead of 10^ and log you can also use e^ and ln, it's basically the same thing. The numbers in the pick random block must have the .0 after them else it just picks 0 or 1.

And then as for actually determining what you rolled, store the random number in a variable (rng), I would put the chances to roll everything in a list and then loop through the list, subtracting the item in the list from the rng var until not( rng < 0 ) and when that happens, the index you're on is the thing you rolled. You could then have another list with for each thing what the reward is.
ScratchAccountCode1
Scratcher
17 posts

RNG system

The
(pick random () to ())
Could help sometimes, but I recommend doing something like my a-90 project, where it tracks your current cursor point with the blocks
set [PASTMP] to (mouse x)(mouse y)
wait () secs
if <[PASTMP] = (mouse x)(mouse y)> then
broadcast [???]
end
I know I didn't really help, but maybe try something like
set [MAORS] to [(whatever u want)]
if <[MAORS] = [1]> then
broadcast [jackpot]


else
broadcast [L]
end
I'm not really good with scratch blocks in text RN sorry
10goto10
Scratcher
1000+ posts

RNG system

LASERLEMONLIME123 wrote:

that can randomly choose shapes using chances such as 1/2, 1/3, 1/4, 1/6, etc.
I think if you want it to randomly choose shapes based on chances, then the chances need to add up to 100.
If you're saying that 1/2 of the time it will choose shape #1, 1/3 of the time it will choose shape #2, 1/4 of the time it will choose shape #3, but then you are over 100%. You can try to change to a individual shape based on those odds but you can't use them to randomly pick a rarer and rarer shape.

I think you might try powers of 2: 1/2, 1/4, 1/8, 1/16

I made this case study that has a costume changing script based on odds. https://scratch.mit.edu/projects/1384334262/

Powered by DjangoBB