Random Number with Seed

Just like the primitive, but generates Pseudo-Random numbers. Useful for games with random level generation. Using this block, you can create "random" numbers that will have the same pattern every time you run another block with the same seed.

Snap! 7.1.4 - Build Your Own Blocks

What PRNG does this use?
Also, the primitive already generates pseudo-random numbers.


You can't set the specific seed though.

The use of a seed is to give the same result every time, but your block doesn't do that, so this is just like the primitive pick random block.

I need to figure out how to reset it if the project stops. Is there any way to detect that?

You can use the when I am stopped block.

Can you name them?

The point of a "pick random with seed" block is that with the same seed, it should always report the same thing every time, even if you close the project and reopen it. Usually, a complex math-based algorithm gives the feeling of randomness, but there's no actual RNG.

Hi, it crash when i tri to get 1000 random numbers: no error, but still running an infinite time

Probably because you're running it with the warp block. If not, I'll check it out,

I know. I made this project with that purpouse.


infinite loop here:

in this case result = infinity

try it

Can you make split the block into 2 distinct block,
1st to init the random seed
2nd to pick a random seeded number

So we can init the seed when we want and multiple time in a same project. (Example: for generating the same random level multiple times in a game when you restart it)

Just to say I made up a seeded random generator a while ago by using a global var to initialise the seed


100000 numbers between 1-100

without seed distribution:
min 936 times max 1071 times

with seed distribution:
min 720 times max 1272 times

Are the random numbers fairly well distributed?

Good project by the way !

Why are these different, then?
Also, it takes longer each time you run the block.

Because there is no way to reset the blocks yet.