Doubts of operation "randi ()"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By leonardo

Because if I do a random number, it repeats itself when the application is run again.
runs and shows me 8,4,1,2 I stop the application I run it again and I get it again 8,4,1,2 are random but the same goes.

Numero=randi() % 20

:bust_in_silhouette: Reply From: picnic

Use randomize() in your _ready function…

Why isn’t this done automatically? Is there a reason the default is consistent random?

nightblade9 | 2018-07-09 22:34

This is normal in most programming languages. Numbers are not random, they are pseudo-random. To get a different ‘sequence’ of pseudo random numbers you have to seed the randomizer, as per the the answer above.

duke_meister | 2018-07-09 22:39