KorbohneD

Make RPGs Weird Again!

Nested probabilities or, who needs math when you can program?

This better be brief. Because it’s late and I don’t feel like doing much thinking anymore.

So, I was faced with a problem. You know how it is when you design stuff and you have to make up rules. Especially when you have to deal with dice and random results, you can’t avoid being confronted with probabilities at some point.
Well, with a single dice it is usually quite simple.
A six-sided dice has six sides (duh) and if it is well balanced and you roll it properly, you have a 1 in 6 chance to roll a certain number. As I said, not hard. You don’t have to be a genius to work that out.
It gets more difficult if you roll two at once and add them up. Suddenly you have a completely different chance with the numbers.

Especially with two six-sided dice there is a kind of ladder in both directions. The 7 is the most common number and the 2 and 12 are the rarest. But that is also not so tricky and not the point for this post, but only the introduction.

So I sit in front of my computer, think about the conflict mechanics, i.e. the comparative throws, and wonder how I could make the whole procedure a little more exciting. It is supposed to be comparative. That’s fine. I want to keep it simple in any case. But nevertheless it can sometimes be that one succeeds very well or even very badly in comparison to the opposing side. That’s what I wanted to depict as well.
I finally decided to use the difference between the two rolls. You compare them anyway to find out the result of the conflict, so it is not much extra work to find out the exact difference.

So it is a certainty that in case of a conflict a comparative toss is made and the higher one wins. But! If there is a difference of X, the winner of the toss may decide if he gets a bonus or the opponent gets a disadvantage.
So far so good.

But now how do I decide what difference I should set in the rules? Two? Six? Nine? Or something else? Thanks to the two six-sided dice, the higher the difference, the less likely it is that someone with a disadvantage or bonus will emerge from the conflict. But what are the odds of that happening? I would like to know that beforehand. I have envisioned that it does not always happen, but only occasionally. So maybe in every fourth conflict throw. In other words, in big, long conflicts it happens a few times, in small, unimportant ones perhaps only once or twice.

Okay, but how do I find that out? Phew… uh… I asked myself this question and at first I couldn’t find a solution. Although I have a math background, I never had stochastics in my study plan. It’s pretty dumb that I actually could really use that with all that RPG design stuff.

Well, let’s first finding out the exact problem.
So I have to find out the probability of how often there is at least a difference of X when comparing two six-sided dice pairs against each other.

Honestly, I didn’t even get into the math. I wouldn’t really know where to start anyway. Instead, I thought, hey, you could easily implement that as code. Set four random numbers, add two of them together, compare them and then see if it’s bigger than the number I just chose.
Simple.

But it is not done with a few comparisons. That doesn’t prove anything.
So I have to compare it more often. Like, a couple million times. The results should be reasonably consistent afterwards.
And while I’m at it, I’ve mechanically looped through all kinds of numbers up to 10, so I don’t have to change them by hand. I’m lazy.

Now this is the ( important part of the ) code:

Code for Percentile Calculation

 

Basically nothing very complicated. It loops through all 10 numbers first. For each number, it rolls exactly 4 dice 1,000,000 times, adds each pair up and compares them. If the difference between the two is greater than or equal to the current number, it increments a counter. In the end, the counter is simply divided by one million, multiplied by 100 and you have a normal percentage.
Many operations, but this way the result is quite accurate.

This is what came out of it:

Difference of the Percentile Values

 

Funny. Of course, I made another small mistake. I didn’t think of the fact that when looping, the first number is of course zero. So first of all it looked whether the difference was greater or equal to zero. Which is always the case. So of course 100 percent is easily achieved. But in the end it was a good thing, because it was a good indication that the code at least partially works correctly.

But after that it gets exciting. I wanted about every fourth toss to make a bigger difference in the conflict. It turns out that according to the result that will be hard to achieve. Every fourth throw would be 25%.
With one third of all throws you have at least a difference of 4. That is a bit much for me. And you have at least a five difference on almost every fifth roll. That’s a bit better. I won’t exactly have it my way, but 20% doesn’t sound so bad. That should be enough for me.

Especially because afterwards I let the whole thing run through again, only this time I gave one of the two throws a +1 and then again a +2.
With a simple +1 not much changes, but with a +2 the percentage value for 5 differences is already 27%. That sounds almost right. So if there is a small power gap between two parties in the conflict, my margin is reached.
Fine with me.

Tell KorbohneD what you think about all this Cancel reply

One Comment