Context: Speedrunning is a way of playing a video game with the aim of completing it as fast as possible. This probability question was inspired by a very simple video game's boss battle, and it is a math question at its core. I tried calculating this myself but made several mistakes and got lost somewhere at n = 2. (Out of curiousity, I also asked some chatty AI friends, and some of them spit out probabilities that added up to more than 1... which from what I remember is a no-no.)
Let's say we have a Boss enemy who only has two meaningful attacks:
- Open (O), an attack that allows the Player to hit the Boss. The Boss chooses this attack 53% of the time.
- Closed (C), an attack that does not allow a hit. The Boss chooses this attack 47% of the time.
We're going to assume our player can land the hit on an Open attack every single time with trivial difficulty. The boss has 5 health, meaning once they use their 5th Open attack, the player wins and the fight ends.
What I couldn't figure out were the formula for the probabilities of getting exactly n number of closed attacks (ideally from 0-10, since anything more than 10 is too slow to continue), as well as what the most likely pattern would be, average pattern (50th percentile result, maybe that's different from the most common?), and what the 80th percentile of luck would look like (not exactly sure whether that should be 80th or 20th, but I mean how many C attacks is so lucky that 80% of attempts would have that many Cs or more.
I tried doing this by hand, but I kind of fell apart trying n = 2 and 3 because I was lost multiplying in all the factors of 0.53 and 0.47, I couldn't figure out a sensible formula to speed up the calculations and I don't think I was doing it correctly anyway. My end goal was to make a table of patterns and their probabilities, but I realized I was in over my head.
As an example, I calculated that the odds of a battle where the boss uses C 0 times are:
(0.53)^5
, since there is only one way for this to happen: Boss has to roll an O 5 times consecutively, at a 53% chance each time.
For the Boss to give us a fight with exactly 1 C attack, I started by assuming the first attack was C. Thus our sequence had to be COO OOO
. The probability of that exact sequence is
(0.47)(0.53)^5
, since the first attack has to be C and then everything else has to be O. Next, I figured there are 5 ways to get a 1-Closed attack fight:
COO OOO
OCO OOO
OOC OOO
OOO COO
OOO OCO
The 6th attack can't be C, since the fight would already be over after getting 5 O attacks and besides, the fight can't end on a C attack since the Player can't hit during that move. Therefore, I figured in the context of a 1-Closed attack fight, any of those 5 configurations would be equally likely, so I just multiplied that by 5 to get
5(0.47)(0.53)^5
. I think that assumption that all 5 configurations are equally likely is a fair one, since we already get to assume there's exactly 1, but I'm not sure - it's been a while since whatever math(s) course taught me this.
OO0 COO
, areO
(capital o) and0
(zero) supposed to be equivalent? They are different symbols… $\endgroup$