My Monte Carlo simulation done in python gives pretty much the same answer for level 9, but even a 1,000,000 tournament simulation hasn't given a level 1 win. Given that I've done it multiple times, I think one of our "programs" is flawed... :/ My program gave this as a result of one 1,000,000 tournament simulation:
[0, 92, 2337, 12022, 33761, 68517, 117765, 179275, 252147, 334084]. It seems that 9's win about 1/3 of the time and 8's about 1/4 of the time. An interesting consequence of the probability function is that it is easier for an 8 to win against a 9 than it is for a 1 to win against a 2, even though both pairs are separated by only one level. I believe this may be skewing it...
Disregard the next two sentences... Plus, in a tournament where all players but one are level 9's and one is a level 1, there is a 1/1,000,000 chance that the level 1 will win. However, even in 10,000,000 tournaments, I haven't seen a single 1 win, which makes me think
my program is flawed...
EDIT: D'oh! I was looking at the "0's", of which there are
no players. In reality, I get an ~.0001063 chance for a 1 to win, which agrees with your result.
Code:
Code: Select all
from random import *
def fight(num1, num2):
total = num1 + num2
z = randint(1,total)
if z > num1:
return num2
else:
return num1
def tourney(levs):
players = []
levels = levs
levelrange = [1,9]
for i in xrange(0,2**levels):
players.append(randint(levelrange[0],levelrange[1]))
# print players
# print ""
for l in xrange(0,levels):
winners = []
for x in xrange(0,len(players)-1,2):
p1 = players[x]
p2 = players[x+1]
winners.append(fight(p1,p2))
players = winners
# print winners
return winners[0]
def montecarlo(times,levs):
w = []
for n in xrange(0,10):
w.append(0)
for i in xrange(0,times):
win = tourney(levs)
w[win] = w[win]+1
w2 = []
for j in w:
w2.append((j*1.)/(times*1.))
return [w,w2]