Skip to content

Instantly share code, notes, and snippets.

@Heril
Last active April 23, 2021 19:45
Show Gist options
  • Save Heril/03d629e64557b9d58cb29de033cf049e to your computer and use it in GitHub Desktop.
Save Heril/03d629e64557b9d58cb29de033cf049e to your computer and use it in GitHub Desktop.
Odds of winning constant probability games against one person

Probabilities and games.

Two simple games used to illustrate certain features of calculating probabilities are as follows:

You and a friend take turns flipping a fair coin. The first person to flip heads wins. If you go first, what are your chances of winning?

You and a friend take turns rolling a fair die with 6 sides. The first person to roll a 6 wins. If you go first, what are your chances of winning.

These end up being very similar problems, and can be generalized.

For convenience, I'll talk about the rolling a die version. To start we'll walk through a couple winning scenarios to look for a pattern.

The simplest way to win when you go first is for you roll a 6 on your first turn. On a fair die, this is simply 1/6.

If you don't win on your first turn, what's the next simplest way to win? Your first roll to not be a 6, your partner's first roll to also not be a 6, and then your second roll to be a 6. The odds of each of these independent events is respectively 5/6, 5/6, and 1/6. The odds of this happening in sequence is the product of these,

eqn7

It might be clear at this point, but every scenario where when you go first that you win, you end with rolling a 6 (1/6 odds) and you and your opponent having an equal number of turns that no one rolled a 6 (5/6 each for both you and your partner), where this can happen anywhere from 0 or more times.

What then are the odds that you win when you go first on your second turn or sooner? Simply the sum of your odds of winning on the first turn, and the odds of winning on your second turn.

eqn6

So to find out your absolute odds of winning when you go first you just need to keep on adding up these winning scenarios. Using infinite sums you can calculate this

eqn5

Where n is the number of turns you take.

For those familiar with infinite sums of geometric series, this can be more conveniently written as

eqn4

(Because 5/6 squared is 25/36)

This fits the form of the common form of when 0<r<1

eqn3

So the odds of this is

eqn2

Given the common form above, this can be generalized for every probability game of the same nature such as flipping coins or other games where you and a partner take turns and the odds of the current player winning is constant.

If the odds of winning during any of your turns is p, where 0<p<1, then the odds of winning at some point is

eqn1

Simplifying this gives

eqn

Taking a look at any possible value for p between 0 and 1, we can see that in going first you always have at least a 50% chance of winning, with those odds increasing as p approaches 1.

graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment