The Regnus Scripting Tutorial
Part 3: Ratios
Now you've got the hang of the basic idea of references, let's take a look at how to better control the probability of certain entries being selected by a reference...
When you set up a list of entries under a particular group in Regnus using the methods you have learned so far, you will no doubt have noticed that each entry is given an equal probability of being selected. This is, of course, correct for many applications.
However, there are also many times when you may want a particular entry to be more or less likely to be selected than others in the same group. A crude way to achieve this, which you may already have thought of, is to simply repeat entries to increase their probability, like so:
GROUP Start
ENTRY <Weighting Example>##Probabilities;
GROUP Probabilities
ENTRY 25%
ENTRY 75%
ENTRY 75%
ENTRY 75%
Here, there is a 75% chance of generating the text "75%", and only a 25% chance of "25%". This works, of course, but is not a very good way of defining probability, especially if you have a lot of entries, as it can quickly become confusing to look at, makes your scripts unnecessarily large, and is increasingly difficult to edit if you need to change particular probabilities.
A far more sensible way to alter the probability (or "weight") of a particular entry being selected is to use the "RATIO" qualifier. This qualifier is used in exactly the same way as an "ENTRY" qualifier, but also allows you to define a probability for the text contained. The syntax for using the "RATIO" qualifier is as follows:
GROUP Start
ENTRY <Weighting Example>##Probabilities;
GROUP Probabilities
RATIO 25:One quarter!
RATIO 75:Three quarters!
Here, we have used two ratio qualifiers to define percentage probabilities for the two entries. Actually, using percentages as in the above example is unnecessary; this example would work just as well written as:
GROUP Start
ENTRY <Weighting Example>##Probabilities;
GROUP Probabilities
RATIO 1:One quarter!
RATIO 3:Three quarters!
This is because the maximum probability is always calculated as the combined total of all probabilities defined, in this case, 4. Thus, the first entry has a probability of being selected of one in four, just as in the previous example, the probability was twenty-five in one-hundred.
You can also mix and match "RATIO" qualifiers with "ENTRY" qualifiers. Standard entries are always given a probability of 1. So, the following example will have the exact same results as the previous one:
GROUP Start
ENTRY <Weighting Example>##Probabilities;
GROUP Probabilities
ENTRY One quarter!
RATIO 3:Three quarters!
Having a quick play with using ratios should soon give you a firm idea of how they work, but although simple, they can be very useful, especially when writing scripts which need to use specific probabilities (for example in research projects or encounter charts and such for roleplaying games), so it's well worth being aware of how to use them!