Random Number Generation in GameMaker manta ray manta ray

June 2022

Time's up!

As with any game jam, I ran out of time and had to cut corners, leave sections incomplete and generally get angry. However, I promise I'll finish this guide even after the jam, and I'm sure you'll still find useful content here.


Welcome GameMaker tribe! In this write-up I made for the GameMaker's Helpful Dev Jam we will be delving a little bit into random variable simulation and some of its applications for gamemaking! I will be presenting some theory, applications and some tips about how to use it.

In short, random variable simulation, also named stochastic simulation, is a fancy term that means to generate some random numbers, with certain characteristics, in order to simulate the outcome of an uncertain event. It is more general than random number generation, which is a particular use case of the former. These concepts have many applications in real life, but I will be discussing some cool uses for game development, including loot drops in your RPG, simulate a realistic population in your tycoon/management game, procedurally generate levels in your roguelike, simulate poker hands in your casino game… The possibilities are endless!


Throughout this write-up we will crawl in a metaphorical dungeon, going deeper and deeper to learn new stuff:

Objectives and Caveats

What this guide is

The main objective of this guide is to compile knowledge and examples that allow game devs to know a bit more about random number generation theory and practice, before blindingly using GameMaker's (or any other language's) random functions.

What this guide is not

This is not a full-blown reference about statistics, random number generation and stochastic simulation. I've oversimplified tons of stuff. Also I'm not a professional game developer, nor an expert in statistics.

In summary, I'm confident you'll find some of the concepts and examples useful for your gamemaking endeavors.


This written guide is intented for beginner to intermediate GameMaker developers. From the statistical point of view, it's aimed at beginners. There’s not really much needed to get a grasp of the concepts presented here, although obviously familiarity with GameMaker (especially GM 2.3+ language features) is strongly recommended. I highly recommend you read all the sections in order, but if you want to skip ahead to a particular section, I won't judge you. I'll just think you fell into a trap door while exploring a higher level of the dungeon.

So, without further ado, let’s venture into the dungeon!