Lab 1: DnD and Probability
Probability and Statistics

Dungeons and Dragons (DnD) is a popular role-playing game. Many computer games are based on its mechanics: Baldur’s Gate, Neverwinter Nights, Icewind Dale, and others. The game has a lot of dice, and the most famous of them is the 20-sided dice (d20).
In DnD, characters undergo various checks — for attentiveness, magic, etc. Depending on the character’s chosen characteristics, they have bonuses to the values rolled on the dice. Also, depending on the situation (and the character’s characteristics), there is an advantage (choose the best value from the rolls of two dice) or a hindrance (choose the worst value from the rolls of two dice).
Let’s say you and your teammates have gone down into a dungeon where a huge dragon guards a powerful artifact. You realize it will be difficult to fight him, so you persuade him to give you the artifact.
The dragon is very wise and has a high level of intelligence. You need to roll a d20 dice and if the result is 15 or more, the dragon will give you the artifact.
Before you talk to a dragon, you can choose one of the following options:
- Drink advantage potion: roll two dice and choose the best result.
- Buff your charisma: add +4 to the result of the dice roll.
Which option will you choose and why?
For those who find the task too easy, I suggest to think about whether the situation can change depending on the difficulty of the test (for example, if the difficulty is 10, will the answer be different) and if there is a pattern, then what is it.
sample(1:20, 1, replace = TRUE)— roll a 20-sided dice.expand.grid(1:20, 1:20)— all possible outcomes of rolling two dice.pmax(sample(1:20, 2, replace = TRUE))— roll two dice and choose the best result.