Rolling Dice the Right Way

John Pentakalos
2 min readMay 18, 2020

https://fivethirtyeight.com/features/can-you-find-the-best-dungeons-dragons-strategy/

Here’s my inelegant, but functioning solution to this week’s FiveThirtyEight Riddler Classic Challenge.

Calculating EV Roll for an “advantage of disadvantage” roll:

What is an “advantage of disadvantage” roll?

The first step then, is to calculate the pmf for the two “disadvantage ”rolls; this will tell us the likelihood, with which we expect to see each possible roll (i.e. how often do you roll each of 1–20) during the secondary “advantage” roll. I took a brute force approach to this by:

a) Computing all possible roll combinations represented by Dice1 and Dice2; (1, 1), (1, 2) … (20, 20)

b) Creating a third vector, DisadvantageRoll, which simply takes the min of the first two. The value_counts() of this column (when scaled to 400 possible combinations) is equivalent to a pmf for a disadvantage roll.

The slightly trickier part is now expanding this same process to the “advantage” roll which takes our two “disadvantage” rolls as inputs. The primary difference between the two problems, is that the original disadvantage roll draws from a uniform distribution, where 1–6 are equally likely to occur, whereas “advantage of disadvantage” draws from the pmf calculated earlier.

Dataframe of each combination and it’s probability of occuring

From here, calculating the EV roll is a cakewalk; it’s just the summation of the DisadvantageProb scaled by the AdvantageRoll (the max of the (Dice1, Dice2) tuple). To calculate the EV roll for “disadvantage of advantage”:

  1. Use a max of first two rolls in calculating the pmf of the two starting advantage rolls.
  2. Use the DisadvantageRoll to scale the computed probabilities in the final EV calculation.

Final Results:

EV roll of advantage of disadvantage is 9.833
EV roll of disadvantage of advantage is 11.167

--

--