Chapter 27
Can You Win The Token Game?
You have one token, and I have two tokens. Naturally, we both crave more tokens, so we play a game of skill over a number of rounds, in which the winner of each round steals one token from the loser. The game ends when one of us is out of tokens, and that person loses. Suppose you are better than me and win each round two-thirds of the time. What is your probability of winning the game?
The Riddler, FiveThirtyEight(original post)
Solution
There are three tokens in all, and your pile performs a random walk on : each round it rises by one with probability and falls by one with probability . You start at and win if you reach before . This is the classic gambler’s ruin.
Let be your chance of winning from tokens, so , , and . The standard solution is Starting from one token, Being the stronger player almost makes up for starting a token behind, but not quite past even odds.
The computation
Play the game: from your one token against my two, transfer a token each round (you take one with probability , lose one with probability ) until someone hits zero, and record how often you finish with all three.
import numpy as np
rng = np.random.default_rng(0)
runs = 2_000_000
wins = 0
for _ in range(runs):
you = 1 # I hold the other 2 of the 3 tokens
while 0 < you < 3:
you += 1 if rng.random() < 2/3 else -1
wins += (you == 3)
print(wins / runs) # ~0.5714 = 4/7