The Hidden Mathematics behind Baldur's Gate 3's Advantage and Disadvantage Mechanics
"Understand the math behind the game's Advantage and Disadvantage mechanics, and how to use it to your advantage."
Baldur's Gate 3 is a game that's the talk of the town recently for being an absolutely massive game (supposedly 75-100 hours just to complete the main storyline with many character and action choices for the players. It's based on the tabletop role-playing game Dungeon & Dragons (D&D).
I haven't played the previous instalments in the Baldur's Gate series or been in a live D&D session, but I'm interested in this game if it were not for the huge time commitment sink... And so, I've instead experienced the game para-socially by watching YouTube videos of the game mechanics.
From the little that I know of Dungeons and Dragons, dice rolls are a core mechanic that govern a huge aspect of the gameplay: from interaction with other characters, the environments and even offensive attacks in battles. Players roll a die and if the value is higher than or equal to the target roll value, your action is successful. This mechanic is no different in Baldur's Gate 3.
One aspect that piqued my interest in Baldur's Gate 3 is the dice rolling mechanic known as Advantage and Disadvantage. When you have Advantage, you roll two dice and pick the higher of the two values. The opposite is true with Disadvantage—you pick the lower of the two dice rolls. Various YouTube videos on the subject mentioned how Advantage is a boon, and that Disadvantage should be avoided at all costs.
Advantage is a boon whereas Disadvantage should be avoided at all costs
Of course based on the description above we can intuitively grasp that Advantage and Disadvantage are important, but just how important are they really? With Advantage, does your odds improve by 20%, double or more? How does the odds change if you roll more than 3 instead of 2 dice?
And so, allow me to take you on a journey down this riveting rabbit hole behind the statistics of dice rolls. We'll (1) develop some basic probability theory, (2) dive into the probability of dice rolls under different cases[1] and (3) I'll share some helpful guides & charts to grok the impact of Advantage and Disadvantage for Baldur's Gate 3 players. For those who are curious about maths, I hope you'll learn something interesting along the way too!
What do we care about?
Fundamentally, what we care about is the probability of a roll $R$[2] meeting or exceeding a specific target value $r$.
$$ P(R \geq r) $$
A Dive into Statistical Theory
What we are interested in above involves the probability of a random variable covering a certain range of values—this is very much related to the concept of a cumulative density function (CDF)[3]. A CDF is typically defined as the probability of a random variable being less than or equal to a target value:
$$ \begin{align*} P(R\leq r) &= 1 - P(R>r) \\ &= 1 - P(R\geq r) + P(R=r) \end{align*} $$
In the equation above, $P(R=r)$ is an example of a probability density function (PDF)[4]—the probability of a random variable taking up a particular value (as opposed to a range of values in the case of CDF).
Rearranging the equation above,
$$ P(R\geq r) = 1 - P(R\leq r) + P(R=r) $$
In order words, to estimate our odds of success in Baldur's Gate 3, we need to know the PDF and CDF of our dice rolls. So let's do so!
Probabilities of a single dice roll
Let's start simple with analyzing a single dice roll. Assuming a regular 6-sided die, the PDF and CDF are as follow:
$$ \begin{align*} P_{regular}(R=r) = \frac{1}{6} \\ P_{regular}(R \leq r) = \frac{r}{6} \end{align*} $$
Intuitively, the probability of rolling any particular number is constant $\frac{1}{6}$ . Meanwhile, the probability of rolling at least a certain value $r$ is linearly proportional to its PDF constant $\frac{1}{6}$.
Dungeon and Dragon games typically use larger-sided dice like a 20-sided die (a.k.a d20
). So generalizing our equations above to an $S$-sided die:
$$ \begin{align*} P_{regular}(R=r) = \frac{1}{S} \\ P_{regular}(R \leq r) = \frac{r}{S} \end{align*} $$
And so, the probability of a successful roll in the game is:
$$ P_{regular}(R\geq r) = 1 - \frac{r}{S} + \frac{1}{S} = \frac{S+1-r}{S} $$
Advantage case
With the simple case solved, let's look at a slightly more complex setup—the Advantage case where you pick the maximum value of two dice rolls.
$$ R = max(R_{1}, R_{2}) $$
The following derivation is heavily-inspired by this StackOverflow post.
Given that:
- $R<r$ if and only if $R_{1}<r$ and $R_{2}<r$
- $R_{1}$ and $R_{2}$ are independent rolls
- $P(R\leq r) =\frac{r}{S}$ (from the derivation of a single die roll)
We can derive the CDF as follows (for brevity, I'm also gonna generalize to $k$ rolls):
$$ \begin{align*} P_{Advantage}(R\leq r) &= P(R_{1}\leq r, \dots, R_{k}\leq r) \\ &= \prod_{i=1}^{k} P(R_{i}\leq r) \\ &= \prod_{i=1}^{k} \frac{r}{S} \\ &= \left( \frac{r}{S} \right)^{k} \end{align*} $$
PDFs can typically be derived by differentiating CDFs. However, since differentiating applies to continuous random variables and we are dealing with discrete random variables, we need to take the discrete difference instead. That's all the say:
$$ \begin{align*} P_{Advantage}(R=r) &= P_{Advantage}(R\leq r) - P_{Advantage}(R \leq [r - 1]) \\ &= \left( \frac{r}{S} \right)^{k} - \left( \frac{r-1}{S} \right)^{k} \end{align*} $$
And so, the probability of a successful roll with Advantage is:
$$ \begin{align*} P_{Advantage}(R\geq r) &= 1 - P_{Advantage}(R \leq [r - 1]) \\ &= 1 - \left( \frac{r-1}{S} \right)^{k} \end{align*} $$
Disadvantage case
Finally, we have the Disadvantage case—picking the minimum value of two dice rolls.
$$ R = min(R_{1}, R_{2}) $$
Following a similar logic as the Advantage case, given that:
- $R>r$ if and only if $R_{1}>r$ and $R_{2}>r$
- $R_{1}$ and $R_{2}$ are independent rolls
- $P(R\geq r) = \frac{S+1-r}{S}$ (from the derivation of a single die roll)
We can directly derive the probability of rolling a target value $r$ (once again, generalizing to $k$ rolls):
$$ \begin{align*} P_{Disadvantage}(R\geq r) &= P(R_{1}\geq r, \dots, R_{k}\geq r) \\ &= \prod_{i=1}^{k} P(R_{i}\geq r) \\ &= \prod_{i=1}^{k} \left( \frac{S+1-r}{S} \right) \\ &= \left( \frac{S+1-r}{S} \right)^{k} \end{align*} $$
For completeness, here's then CDF and PDF for the Disadvantage case:
$$ \begin{align*} P_{Disadvantage}(R\leq r) &= 1 - P_{Disadvantage}(R\geq [r + 1]) \\ &= 1 - \left[ \frac{S+1-(r+1)}{S} \right]^{k} \\ &= 1 - \left( \frac{S-r}{S} \right)^{k} \end{align*} $$
$$ \begin{align*} P_{Disadvantage}(R=r) &= P_{Disadvantage}(R\leq r) - P_{Disadvantage}(R \leq [r - 1]) \\ &= \left[ 1 - \left( \frac{S-r}{S} \right)^{k} \right] - \left[ 1 - \left( \frac{S-(r-1)}{S} \right)^{k} \right] \\ &= \left( \frac{S+1-r}{S} \right)^{k} - \left( \frac{S-r}{S} \right)^{k} \end{align*} $$
With that, here's the summary of our derivations so far:
Case | PDF ($P(R=r)$) | CDF ($P(R\leq r)$) | Roll success probability ($P(R\geq r)$) |
---|---|---|---|
Regular | $\frac{1}{S}$ | $\frac{r}{S}$ | $1-\frac{r-1}{S}$ |
Advantage | $\left( \frac{r}{S} \right)^{k} - \left( \frac{r-1}{S} \right)^{k}$ | $\left( \frac{r}{S} \right)^{k}$ | $1 - (\frac{r-1}{S})^{k}$ |
Disadvantage | $\left( \frac{S+1-r}{S} \right)^{k} - \left( \frac{S-r}{S} \right)^{k}$ | $1 - \left( \frac{S-r}{S} \right)^{k}$ | $\left( 1-\frac{r-1}{S} \right)^{k}$ |
where
- $R$ is the discrete random variable representing the roll outcome
- $r$ is the target value
- $S$ is the side of the die
- $k$ is the number of dice rolls
It's interesting to see in the final column how there's a recurring term $\rho=\frac{r-1}{S}$ and how all roll success probabilities have a variation around an inherent expression $1-\rho$. Keep this in mind, as like any good Chekov's Gun, we'll see that this seemingly random fact isn't as random as we think.
Verification
Let's quickly check that the derivations are correct. Suppose we have a six-sided die ($S=6$) and two dice rolls ($k=2$) for Advantage and Disadvantage, the probability to roll a five or higher ($r=5$) is:
Case | $P(R\geq 5)$ |
---|---|
Regular | $1/3$ |
Advantage | $5/9$ |
Disadvantage | $1/9$ |
If we lay out all possible outcomes of rolling two dices independently on a grid, here are the successful events for Advantage and Disadvantage.
Observe how they resolve to the probabilities calculated in the table above.
Applying this to Baldur's Gate 3
That's quite a lot of math derivations. Phew! 😅
Without further ado, let's how the fruits of our labour apply to Baldur's Gate 3's Advantage and Disadvantage mechanics—the whole reason I started my digging down this rabbit hole in the first place!
I haven't played the game nor am very familiar with D&D. That said, from my understanding, Baldur's Gate 3 uses a 20-sided die ($S=20$) and two dice for Advantage and Disadvantage rolls ($k=2$). With that, we can already compute and compare the probability of successful rolls for different target values $r$:
Target roll ($r$) | Disadvantage | Regular | Advantage |
---|---|---|---|
1 | 1 | 1 | 1 |
2 | 0.9025 | 0.95 | 0.9975 |
3 | 0.81 | 0.9 | 0.99 |
4 | 0.7225 | 0.85 | 0.9775 |
5 | 0.64 | 0.8 | 0.96 |
6 | 0.5625 | 0.75 | 0.9375 |
7 | 0.49 | 0.7 | 0.91 |
8 | 0.4225 | 0.65 | 0.8775 |
9 | 0.36 | 0.6 | 0.84 |
10 | 0.3025 | 0.55 | 0.7975 |
11 | 0.25 | 0.5 | 0.75 |
12 | 0.2025 | 0.45 | 0.6975 |
13 | 0.16 | 0.4 | 0.64 |
14 | 0.1225 | 0.35 | 0.5775 |
15 | 0.09 | 0.3 | 0.51 |
16 | 0.0625 | 0.25 | 0.4375 |
17 | 0.04 | 0.2 | 0.36 |
18 | 0.0225 | 0.15 | 0.2775 |
19 | 0.01 | 0.1 | 0.19 |
20 | 0.0025 | 0.05 | 0.0975 |
Here's an interactive graph to help visualize this better:
We can see that the probability of success decreases linearly by $\frac{1}{S}$ with the target value $r$. This makes intuitive sense—you have one less possibility of success (i.e. the $r$-th die value is no longer in your favour) when the target $r$ increases by one.
What's interesting to me is how much Advantage and Disadvantage skews the odds in or against your favour. Taking an arbitrary value of $r=10$, we can see the success probability is lowered by 25 points and increased by 30 points from the baseline with Disadvantage and Advantage respectively. Put another way, you have a slightly higher than 1:1 odds of success for rolling $R\geq 10$. That odds of success drops to roughly 1:3 with Disadvantage and increases to 4:1 with advantage—very substantial difference that compounds with every successive roll of the die with Advantage or Disadvantage at play!
What's just as interesting is how the differences between the three cases trend—the skew is most pronounced in the middle, and diminishes at the extremes of $r$. In other words, Advantage and Disadvantage effects are most apparent for the "middle" or interquartile region (IQR) of target values $r$. However, a player still shouldn't discount the mechanic for high target value rolls—in the case of $r=20$, Advantage almost doubles your chances, whereas Disadvantage reduces your chances by a whopping 20-fold!
The challenge term $\rho$ and scaling with number of dice rolls
Recall that from deriving roll success probabilities, we encountered a recurring term $\rho=\frac{1-r}{S}$ and variations around an inherent expression $1-\rho$ . We can see these play out in the chart above. I like to think of $\rho$ as a "challenge term" that increases (linearly) with our target value $r$.
In the case of a regular die roll, the roll success probability ($1-\rho$) decreases linearly, as we've reasoned previously. In the Advantage case ($1-\rho^{k}$), the challenge term diminishes geometrically by the number of dice rolls—remember $\rho$ is always a fraction that's less than 1. Meanwhile, in the Disadvantage case $(1-\rho)^{k}$, the linear probability of success (a fraction less than 1) is geometrically discounted by the number dice rolls—super costly, and definitely should be avoided at all costs!
Conclusion
We took a dive into the statistical derivations behind dice rolls and the Advantage and Disadvantage mechanics for Baldur's Gate 3. We also visualized and qualitatively reasoned why Advantage and Disadvantage are such a big deal in skewing Lady Luck in or against the player's favour!!
I hope this guide was useful to better intuit the effects of Advantage and Disadvantage for those getting their feet wet with Baldur's Gate 3, which is out now on PC and soon on console. Also, I hope those interested in math and D&D also found this dive fun 🤓!
Personally for me, this curiosity led to a longer blog post than I expected. Nonetheless, it was fun and eye-opening in many ways—an exercise in statistics, in publishing something for the first time and an opportunity to gain some invaluable skills (using Obsidian's LaTeX plugins, publishing a blog post, marketing it) along the way!
Addendum
ChatGPT for mathematical derivations
I found ChatGPT to be surprisingly able to come up with proofs and derivations (at least to the un-trained mathematician in me). It needs to be guided a little, however, as for my case it incorrectly differentiated the CDF to obtain the PDF which gave invalid results, since dice rolls are discrete probability events.
LaTeX with Obsidian
I've recently swapped over to using Obsidian as my primary note-taking and knowledge management app, and I found it to be a breeze. Writing this article is an excuse for myself to try out and incorporate LaTeX tooling in Obsidian in my writing workflow. I must say that writing in LaTeX with Obsidian is a breeze, especially with the LaTex Suite obsidian plugin! You express your equation in natural syntax like x/y
and the plugin substitutes what you typed with correct LaTeX syntax—$\frac{x}{y}$
. This is an ergonomic game-changer to fast and frictionless LaTeX usage, and something I wished I had while working on my Masters thesis back in the days 🥲
1. I was encouraged to do first-principle derivations of the probability after watching how 3Blue1Brown explained it so simply and elegantly on the related topic of convolutions—"What is probability distribution of the sum of two random variables?"
2. In statistics, random variables are typically denoted with capital letters
3. It's technically more accurate to refer to this as a cumulative mass function (CMF) in our example since a dice rolls are *discrete* random events. CDFs are used for continuous random variables, but I'm not gonna be super pedantic about it in this blog post.
4. Technically probability mass function (PMF) for the discrete case.