# Make a fake random distribution?

Sometimes a "real" random event seems unfair and makes players frustrated. For instance a enemy has probability of 20% to cause double damage("critical hit"). Thus he could make 4 critical hits in a row with 1/725 probability. It's not as small as it sounds.

I hope the probability could be adjusted after each hit. If the player just got a critical hit, the probability decreases for the next hit. Otherwise it increases.

Is there a mathematical model for this behaviour?

You may wish to completely rethink what "critical hits" do in your system and why you're using them. "Well, other RPGs use them!" is not a valid reason. One warning sign of a skewed design is the need to apply more and more special rules.

Any kind of random bonus takes away from direct, tactical player skill and adds to strategic planning (RPG item load-out, prioritizing stats on gear, etc...). Because of this shift of focus you have to decide what your game is about before wantonly applying old standards like criticals and fumbles.

My suggestion is that if you want randomness to take any part in your game then glory in it, let it be random.

But if you really want to add more arbitrary rules you can simply start a countdown when the first critical happens and during that countdown any more criticals are reduced to 50% and then 25% and so on. Each critical, of course, resets the countdown. This gives you two places to tune your arbitrary rules: how long is the countdown and how much reduction is accumulated at each critical. A combination of those two controls lets you clearly avoid the unspoken problem of "what if the boss gets a critical, then normal, then second critical?" that a simple chain check wouldn't fix.

Dota 2 uses PRD (pseudo random distribution) which doesn't significantly affect the expectation, but decreases the chances of a streak, e.g. bash streak. Have a look at this, explains everything in detail. http://www.youtube.com/watch?v=KdS-K_rosCI

• In fact it doesn't. It just introduces the concept without any details about this algorithm. Sep 23, 2013 at 14:17
• @LaiYu-Hsuan It does, the basic version video may make it a bit easier to understand: youtu.be/yR7BcWfBCsc Sep 23, 2013 at 14:52

I think this is a case where trying to be too smart will lead to a spiral of tweaks and adjustments to the random number generator that will make it very complex.

The answer might be in the question: if a player may get frustrated by too many critical hits in a row, well, directly reduce the odds of this happening. If the RNG draws a 4th critical in a row, you may for instance wish to re-roll it. Or even enforce critical = false.

One fairly common approach you can use that should give the results you're after: rather than rolling a die every time, instead pick a card : suppose you have a 1/10 chance of 'critical failure', a 4/10 chance of failure, a 4/10 chance of success, and a 1/10 chance of 'critical success'. Then rather than rolling a (metaphorical) d10 and handling the result, instead shuffle a stack of ten (virtual) result cards and deal them out, one by one, whenever you need to generate such a result. When you run out of your deck, just reshuffle and start dealing again. This can still generate back-to-back critical failures, but it guarantees that there will be success (and critical successes) within some reasonable span. If you want things to be not so obvious (and don't mind introducing a small chance of successive extreme results), you can always 'double up' your deck; build a stack of twenty cards which contains two copies of each result and shuffle that instead. (Note that in the limit of putting infinitely many copies of the deck together and shuffling them, this becomes exactly the roll-a-die approach.

• This is a great answer. It's the equivalent of: if you want 10 random numbers from 0 to 100, rather than getting a random number 10 times, you just generate an array with all possible options (0, 1, 2, ..100) and shuffle it, then use the first 10. This avoids repeats so it's not quite an equivalent, but in many cases it's a much better solution.
– zeh
Sep 24, 2013 at 13:58

Bayesian Inference deals with situation quite a bit. You start with a probability distribution for an event occurring, then once it does, you update this probability to a new one. These are the prior and posterior probabilities respectively. It's often most useful to view this in tree form (grabbed this off the internet).

In the tree, the branches represent the probability of taking that branch, and the nodes are the event. So in your case, let's make A,B,C the events of getting a critical hit with attacks A,B, and C resp. Then P and NP will be the events of getting another or not. We notice that at point (B -> P) there is a 25% chance of getting another critical hit given that you got one the last turn. Of course your tree wouldn't look just like this, but it's the best I could do in 5 minutes.

• Baysian inference has nothing to do with this! Sep 23, 2013 at 17:38
• @starwed then would you like to offer a different term rather than simply yelling at me? Sep 23, 2013 at 18:14
• @Jeremy, you need to answer how to solve the OP's problem. So far, you have just reworded his question with a mathematical illustration. But that doesn't tell the OP how to make the RNG more fun. Sep 26, 2013 at 20:25

I think there are already some nice answers given above but would suggest a different approach.

When the player makes a critical hit you are giving him a small reward to entice further play. Sort of like how a gambling addict will stay at the poker table for 'just a little longer' after winning a hand. When the enemy gets hit by a critical it might not be increasing the game experience at all but rather just feel unfair, especially if that was what made them lose the fight.

Thus my suggestion would be to just keep the crits for the player and not use them for the enemies at all. After all the player is a hero and should be favored by the gods themselves to achieve greatness :)

Here are random-but-not-completely random techniques I use.

1) Shuffle bag. Put all valid outcomes in a bag, choose one randomly and remove it from the bag. Repeat until the bag is empty then refill the bag. To add back in randomness, refill the bag when it only has X items remaining.

2) Progressive percentages. First roll X% chance, if fails second roll is X+Y%, then X+2Y% etc. Reset to X% on success. Both the start value, and progression can be adjusted (even non-linear).

3) Internal cooldowns. Roll X& chance, if success, do not roll for next N seconds or M attempts or whatever. Can be combined with other methods. To add in more randomness have multiple event checks with different coodlowns, ie make 2 rolls at 25% with 3 and 7 second internal cooldowns as opposed to 1 roll with 50% with a 5s icd (not exactly the same probability, but you can calculate and match if important).

4) Pre-rolled spacing. Rather than checking vs a percent each event, simply choose when the events happen. For example, "this boss crits every 1d4+4 attacks." Works well when the want something to happen relatively consistently, and somewhat random, but you don't want back to back events. In someways a special case of methods (2) plus (3). Again for more randomness you can have 2 or more overlapping sequences.