Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comparison of Tournament Finals Formats
A = 0.5
B = 1 - A
import random
def boX(X, a_chance, adv=0):
"""
Given two teams where team A has an `a_chance` to win and an `adv`
game advantage, this simulations one best-of-`X` game.
"""
a, b = adv, 0
to_win = ((X + 1) / 2)
while a < to_win and b < to_win:
if random.random() <= a_chance:
a += 1
else:
b += 1
return a == to_win
double_bo3, bo5_adv, bo5_noadv = 0, 0, 0
N = 1000000
A = 0.5
for i in xrange(N):
if boX(3, A):
double_bo3 += 1
elif boX(3, A):
double_bo3 += 1
if boX(5, A, 1):
bo5_adv += 1
if boX(5, A, 0):
bo5_noadv += 1
print "double bo3: {}".format(100.0 * double_bo3 / N)
print "bo5 with 1 game advantage: {}".format(100.0 * bo5_adv / N)
print "bo5 with no advantage: {}".format(100.0 * bo5_noadv / N)
@Noxville
Copy link
Author

Noxville commented Apr 26, 2015

Sample results:
double bo3: 74.9473
bo5 with 1 game advantage: 68.7583
bo5 with no advantage: 50.0155

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