• 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!

Random number generator, gathering statistics

D

Dawid

Guest
Hi,

I make prototypes for slot games. I am considering using Game Maker. However, I need playable versions, as well as simulations that would run a million times and return some statistics. Is it possible to do that in Game Maker?

Thank you in advance for help.
 

Tsa05

Member
Yes.

Suppose you have 3 wheels with 20 positions.
Code:
var file = file_text_open_write("position.csv");
repeat(1000000){
     var p1 = irandom(19);
     var p2 = irandom(19);
     var p3 = irandom(19);
     var toWrite = p1+","+p2+","+p3;
     file_text_write_string(file, toWrite);
     file_text_writeln(file);
}
file_text_close(file);
You now have a million-line text file in your local appdata folder with 3 spins, 0-19, on each line.

You could also generate those 3 results and then draw an image strip that loops behind the window of the slot for a playable version.

If you *are* going to use GameMaker for gambling-type games, be certain to call the randomize() function before making a playable build!!!!!!!!!!!!!!
GameMaker uses a fixed random seed for each game project, making it much easier to test and debug code (the sequence of numbers generated is identical each time the game is played). Calling randomize() at the start of your game will choose a different seed.
 
Top