An Introduction to Probability Tables
In this tutorial, we’re going to look at using the Advanced Random (AR) plugin's probability tables feature. We'll be looking at setting up tables right the way through to creating basic random encounter and random item systems. You’ll see there are two example projects attached to this tutorial – one demonstrates the basics of probability tables, including creating and populating them, whereas the other shows building tables in bulk from project files, making changes to them at runtime and more!
The Advanced Random plugin is really useful for a variety of things, notably procedural generation via its noise-generation functions. But it also allows you to build permutation and probability tables, the latter of which we’ll be focussing on in this tutorial.
But what can we do with probability tables?
Well, the basic use of a probability table is to generate weighted random numbers. So, let’s say we have three entries in this table ‘ObjectA’, ‘ObjectB’ and ‘ObjectC’. We’ll give A a weight of 1, B a weight of 2 and C and weight of 4. In this example, ObjectC is the most likely entry to be picked from the table, as it has the biggest weight. However, we can also say it’s roughly four times as likely to be picked than ObjectA.
In game terms, we can use these to create systems that need a random element. You could use them for loot drops upon defeating an enemy, discovering random items in the overworld, random upgrades when a character levels up, encountering enemies, the list goes on! We’re going to focus on two examples later in this tutorial – random item boxes and random encounters a la Pokemon.