• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [solved] random numbers aren't random, just patterned.

A

Adhiesc

Guest
I'm currently trying to make a match-3 game, and suddenly found out that every time the game starts and restarts (with game_restart), the ~irandom~ for the image indexes I made results the same pattern over and over each time the game is executed. like this:

When game starts

When game is restarted once

etc. they are the same pattern over and over.

I wonder is there a way to avoid this to happen?
 
A

Adhiesc

Guest
~Sorry, solved it myself~
I forgot to read the help document's details about irandom.
I found out that I must use randomize() at the start of the game.
:p
 
S

Snayff

Guest
You can also use it before each random call if you want the random structure to vary before each call, though the value likely depends on the save structure.
 
E

elementbound

Guest
Calling randomize before each random call is unnecessary, and possibly degrades the quality of random numbers. If you call randomize once, you get a properly working pseudo-random number generator. If you call it every time, you just get a function that uses the current time to output some number.
On the surface, both seem random, but I would highly advise against calling randomize() all the time.
 
I have, a long time ago, run tests with calling 'randomize()' repeatedly, and it led to results that were much less random. There really is no benefit to calling randomize more then once. The algorithm is sufficiently pseudo-random enough, and the odds of getting the same seed is rather small.
 
A

Adhiesc

Guest
Yea. I agreed with not calling randomize() repeatedly. :3 It's already sufficiently randomized.
 
S

Snayff

Guest
Ah, OK, looks like I was mistaken on that then so best not to use randomize() repeatedly! Thanks for clarifying, peeps.
 
Top