Discuss Scratch

fishu4
Scratcher
100+ posts

Probability issues with movement and others

So, I have a problem where the variable only is 1 if a 1 in 7000 check is met. Though, the move block *should* only move when the 1 in 7000 is activated, but instead, it moves in so about one in two chance. Please help.
Link to project
whenclickedforeverifpickrandom1to7000=1thenmove10steps still moves even in the chance is not landed.setactually correctto1 only changes when the chance is landed.elsesetactually correctto0 when the chance is not landed.
i really need help with this. I have never had an issue like this before. Please help.

Last edited by fishu4 (Sept. 13, 2023 15:10:58)

-TUB-
Scratcher
100+ posts

Probability issues with movement and others

When there aren't any visible changes to the stage, scratch runs scripts as fast as possible, so the script will loop over and over until the condition in the if statement is met. This can be seen by incrementing a variable every time the forever loop runs. You will see that the loop is running much more often than 1 time per second. The only time scratch delays the loop is when the cat moves forwards, which is when the condition inside the if statement is met. The result is that the cat appears to move consistently each frame.
HoodieGuy64
Scratcher
100+ posts

Probability issues with movement and others

Scratch is running it as fast as it can, so there's a much higher chance that the conditions are met. You can put a
wait0secs
block so it only runs one time per second
roomhj
Scratcher
16 posts

Probability issues with movement and others

you can try to 1 to 7000000
ifpick random (1) to (7000000)=1thenchangexby20

Powered by DjangoBB