Created
April 26, 2015 13:34
-
-
Save Noxville/04cf07b08b3ee1e157c7 to your computer and use it in GitHub Desktop.
Comparison of Tournament Finals Formats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample results:
double bo3: 74.9473
bo5 with 1 game advantage: 68.7583
bo5 with no advantage: 50.0155