Pseudo-Random Distribution (henceforce PRD) is a neat little trick I learned from Warcraft III of all places that allows you to make random variables less 'random'. The idea is, instead of having say a 20% chance to critical strike for your main character, you can have a distributed chance to critical strike on each attack that gets progressively higher, forcing an average of "one in five", a 20% chance overall, while making it extremely unlikely to get chains of criticals in a row, and making it impossible to go an entire game without getting any.


All random variables on computers are not actually random, but pseudorandom in nature; its impossible to create a program that will return a truly random number. Instead the computer uses some ridiculously complicated formula that comes out to be approximately the proper chance of returning each number. Thats not what this article is about. But because of the limitation of these formulas, theres a special importance on making random events in games better distributed. This is where PRD comes in. Especially in games that are player vs player, it cuts down on the 'luck' factor, and makes random skills more 'consistent'.

In its basic form, PRD works like this:

You have an event that has an X% chance of occuring on some call, for example, in MMF2:

Random(100) < 30

Would give you a 30% chance. Now you keep track of how many SUCCESS'es and how many FAILURE's this event has; every time the check fails, you add 1 to a counter, every time the event succeeds, you reset that counter to 0. Now, you use a variable called "Q", a predetermined constant, and alter the formula to this:

Random(100) < Q * #Failures

In the case of 30%, Q happens to be 11.895, or 0.11895. Obviously you need to use a Random(100000) if you want to this be more exacting. What happens when you do this is this; one the first attack, you have an 12% chance of striking. One the 2nd attack, you have a 24% chance. On the 3rd, a 36% chance. And so on. If you made it to the 9th attack, you have more than a 100% chance to strike. Overall, the distribution of these chances will mean you have a 30% chance to strike on average, but it will be 'less random'.


Now if you've followed this so far, the thing you probably noticed is this magic number Q. Its very hard to calculate, and I'm not going to get into how you do that, but instead just provide a table. For every % chance, this constant is always the same. Hence, for actions that fall on these specific odds, you can use this distribution:

5% 0.00380
10% 0.01475
15% 0.03221
20% 0.05570
25% 0.08475
30% 0.11895
35% 0.15800
40% 0.20155
45% 0.24933
50% 0.30213

I'll include a more expansive list below. But these cover most of it. In general, this lets you create a much more 'stable' random event system, which further improves upon the random number generators in MMF2. The built in one is extremely weak and repeats alot, and thus you need to use extensions for some projects, and this is a good way to improve upon those extensions to get good distribution. This example file will demonstrate a graph of HOW the normally distributed and PRD differ in a large sample size when working with a 1/10 chance; it records the # of 'attacks' inbetween each '30%' critical strike;

http://claniraq.googlepages.com/RandomTester.zip

Image


As you can see, 30% of the time it occurs on your first strike for normal distribution, then 20%, then 15%, 10%, 7.5%, etc. Hence it is very LEFT-skewed distribution; it favors chains of critical strikes in a row, yet, at the same time, the #10 is very heavy because it includes all the outlier (>10) data, showing that a good 5-10% of the time, you will take MORE than 10 strikes in a row on a 30% chance of attack, something that should occur roughly every 3-4 strikes.

Meanwhile, in our PRD graph, the distribution is directly curved to the 3-4 strike zone; it will always take 2, 3, or 4 strikes between attacks, a bell curve distribution centered properly. You will NEVER seen any outlier data here; you can't go long streaks without getting a strike.


Big list of constants;
5-50% in intervals of 5:
5% 0.00380
10% 0.01475
15% 0.03221
20% 0.05570
25% 0.08475
30% 0.11895
35% 0.15800
40% 0.20155
45% 0.24933
50% 0.30213

1-30% in intervals of 1:
0 0.00000
1 0.00013
2 0.00058
3 0.00135
4 0.00241
5 0.00378
6 0.00543
7 0.00736
8 0.00956
9 0.01203
10 0.01476
11 0.01776
12 0.02100
13 0.02449
14 0.02824
15 0.03222
16 0.03644
17 0.04090
18 0.04560
19 0.05052
20 0.05567
21 0.06105
22 0.06664
23 0.07246
24 0.07849
25 0.08473
26 0.09117
27 0.09783
28 0.10468
29 0.11173
30 0.11898


I lost my list of constants of each for up to 100%, but it is NOT a very good idea to apply PRD to events with a 50% or more chance of occuring, anyway; if it would have had a 99% chance of occuring, the PRD would effectively be 99, FORCING the strike to occur on an odd numbered attack. Plus, when in gods name do you use > 50% chances of things occuring? Why not use the chance of the event NOT occuring? Hence theres no reason whatsoever to use above 50%. Sorry I don't have non-5 intervals between 30 & 50