1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Random number generator, gathering statistics

Discussion in 'Programming' started by Dawid, Feb 11, 2019.

  1. Dawid

    Dawid Member

    Joined:
    Feb 11, 2019
    Posts:
    1
    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.
     
  2. Tsa05

    Tsa05 Member

    Joined:
    Jun 21, 2016
    Posts:
    497
    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.
     
    Bayesian likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice