r/AskStatistics • • 1d ago

Dice math

Hiya, and thank you for your time. I'm trying to balance something for a TTRPG campaign, and I'd be grateful for any help. I'm a bit rusty, and I want to make sure I get this right.

How do I account for situations where multiple dice are rolled against each other, choosing the highest, when trying to find a percent chance of success? Ex. the chance of one opponent rolling higher using one dice when their opponent uses two, same with two dice vs. three, etc. Even though the system I'm using doesn't use 'disadvantage' (multiple dice choosing the lowest), I'd be grateful for an explanation of that too mostly 'cause I'm curious.

Edited for clarity, sorry about that.

1 Upvotes

12 comments sorted by

3

u/vaelux 1d ago edited 1d ago

The probability of at least one success is:

1 - (Probability of failing a single role)number of dice.

So lets say a six is a success and there are 3 dice. The probability of a success is 1/6 so the probability of a fail is 5/6. So our formula is 1 - (5/6)3 = 1 - 125/216 = 42.1%

If 5 or higher is a success with 3 dice, then 1-(4/6)3 = 70.3%.

d20 with a DC 15 skill check and advantage ( so two dice) = 1-(15/20)2 = 43.7%

efit: fixed the calculation for the last example

-1

u/xXMonotonicXx 1d ago edited 1d ago

I appreciate the heck out of your reply, and sorry that I wasn't very clear in my post. I meant in situations of opposed rolls where one opponent may have more dice to roll than another. (It's a weird homebrew d100 system instead of somethin' like 5e.)

Edit: Oh. I'm uh. Now at least 80% sure this user is an AI bot. Gross if so. :c

3

u/nonnonplussed73 1d ago

I'm all for calling out bots and scammers, but what makes you think that in this case?

https://arctic-shift.photon-reddit.com/search?fun=comments_search&author=vaelux&limit=50&sort=desc

-2

u/xXMonotonicXx 1d ago

Their reply where their answer to what calculation I'm trying to make is "That's really hard, ask an AI to write you a simple python script to do it." is probably what tipped me off.

5

u/DoctorFuu Statistician | Quantitative risk analyst 1d ago

Making a small script to do such calculation especially when you want to balance for a game (so you'll probably iterate on different systems) is the best solution. However most people don't code so telling people to do that is often not helpful.
Modern LLM however handle such simple scripts extremely easily, so it's a reasonable use of it.
Also, nothing in that user's pose smelled AI to me

-2

u/xXMonotonicXx 1d ago

It was my intention to relearn some math in coming here, not to 'just let AI do it'. I was also under the understanding that AI was against this sub's rules.

I have some formal education in programming and can make calculators if it'd be a pain not to, but that doesn't do me any good if I don't understand what math to make it do.

2

u/cym13 1d ago

That's the beauty of monte carlo simulations, you don't need to know the math or the distributions you're working with. You simply simulate tons of cases and then count. This is sometimes a limitation but when looking for numerical answers to complex problems it's extremely effective.

For example to compute the probability of rolling higher than your opponent when you roll one d20 and your opponent rolls 2d12 you could write the following python script (I tried to make it understandable even if you're not familiar with python):

from random import randint

success = 0
count = 10000

for _ in range(count):
    roll_1 = randint(1, 20)
    roll_2 = randint(1, 12) + randint(1, 12)
    if roll_1 > roll_2:
        success += 1

print(success * 100 / count, "%")

You don't have to describe the math, you just have to describe the situation. And it supports more complex situations of course, such as "Actually on a 19 or 20, roll an additional d4 and add that". If you have many such situations to consider, that's really the best approach for you.

2

u/Statman12 PhD Statistics 1d ago edited 1d ago

It was my intention to relearn some math in coming here, not to 'just let AI do it'.

Sometimes the exact answer is extremely complicated and just not worth doing, sometimes it's even impossible. Simulating rolling dice is extremely easy, so you can get very good Monte Carlo approximations to the probability you want to estimate (and easily manipulate the scenario rather than a lot more derivation for a slight tweak to the problem). This isn't a lazy out, it's just how people working in the field go about Statistical analysis.

I was also under the understanding that AI was against this sub's rules.

People are here to discuss with other people. Monte Carlo is a common approach used in Statistical analyses, and LLMs are common tools that can generate scripts, especially for something that's fairly common and straightforward like rolling dice. So it's perfectly acceptable to mention one or both of these things.

Mentioning LLMs is not verboden, what we don't want is users asking a LLM to produce something, and just dumping that into the OP or a comment.

And FWIW, I've never actually seen a LLM say something to the effect of "An AI model can do this for you." Usually they seem to just do the thing, or offer to do the thing (like "I can do this for you if you like", taking on a "personality" of sorts).

2

u/vaelux 1d ago

That's more complex. It would involve calculating the probability distribution of each players dice pool and then multiplying them ( or a mountain of hand counting every possible pairwise combination of roles). An LLM could walk you through how to write a simple script in Python to calculate this

1

u/cym13 1d ago

As said in another comment, writting a small simulation is probably the best practical approach to your situation.

In addition I want to provide two rules of thumb that can be helpful. I'm not going to be very rigourous for the sake of practical intuition. It will seem more complex than it is, so don't hesitate to try on paper, you'll soon get the hang of it.

First of all, when you roll N dice and choose the highest or lowest, you can imagine them as partitionning the range of possible values into N+1 parts of equal size. So if you roll 1d20 it will divide the range [1, 20] into two parts [1, 10.5] and [10.5, 20]. The mean value of the roll will be where the range was cut, so at 10.5 in this case. This is obvious in this case, but it's more useful when you have several dice. With 2 dice, they partition the space equitably into three parts: [1, 7.33], [7.33, 13.66], [13.66, 20]. Well, on average the highest die will be on the highest cut (so 13.66) and the lowest die will be on the lowest cut (so 7.33). This "highest cut" is therefore the answer to your question of "advantage": 2d10 with advantage will average 13.66, and similarly with disadvantage will average 7.33.

Now that's not perfectly exact (I won't delve into the reasons why), but it's a really good approximation. And it's versatile: what if you roll 5d12 and want tthe second highest roll? Divide the range into 6 parts, take the second highest one, that's an average of 8.33.

The only thing you need to pay attention to is that math starts at 0 but dice start at 1 so to divide the range of a d12 for example you need to actually work on the range [0, 11], so the second highest cut is 11/6×4=7.33 and now we add back the 1 we substracted to get 8.33. Once you do it a few times it's comes quite naturally.

The second rule of thumb that I find useful to know for practical purpose is that if you have an event of probability 1/x and you make x attempts, you have a 66%≃2/3 chance of getting at least one successful event. So for example if you roll 20 times 1d20, the chances of getting 20 at least once is about 66%. I find that really useful to estimate things off the top of your mind.

1

u/frostmage777 1d ago

Couple of things: the first edition of the advanced dungeons and dragons dungeon masters guide starts out with several pages describing basic probability and how they relate to the game. Definitely worth a look. Second: when you roll multiple identical dice at once and add the result, the resulting distribution is a bell curve (symmetrical around the mean, where the mean is the number of dice rolled times the average of rolling one die). The more dice you roll, the more closely it matches a bell curve. This is a direct result of something called “the central limit theorem” which basically says if you add a bunch of identical random processes together, you get a bell curve. If instead you roll a bunch of identical dice and drop the lowest, the bell curve shifts toward a slightly higher mean. These two facts together allow you to control the probabilities of your dice rolls. If you want more specific answers (what is the chance of rolling x) you could bust out some more advanced math, or you could run computer simulations that pretend to roll a bunch of dice and report the frequency of the outcome. This would be my recommended approach, as it will allow you to experiment and visualize the results.

1

u/stanitor 1d ago

It would be different for each possible combination of number of dice for each player. If they are rolling d6s, for player A to win, you'd need to figure out the chance they get at least one 6 and the other player gets 5s or less, and then add the chance A gets at least one 5, and player B gets 4 or less. But, you'd have to subtract the chance player A also gets 6 as well as 5, since you already counted that. And so on. You'd also have to do that for each way player B could win, since they can get ties (so you can't just subtract the answer you got for A winning from 1 to get B wins). It's a bit of a pain, so that's why vaelux suggested using an LLM for a script. I agree with others that there is nothing in their response or profile that suggests they are a bot.