In [1]:
#Updates distribution with a new score and probability, or adds more likelihood to an existing probability.
def updateNewDist(new_dist, d, p):
    
    #If the score difference already exists, add the additional probability.
    if d in new_dist.keys():
        new_dist[d] += p
    #The score does not exist, so add its corresponding probability.   
    else:
        new_dist[d] = p
    
    return(new_dist)


#Given a distribution of scores, all possibilities of the next possession are calculated and 
#a new probability distribution of scores is produced.
def updateDist(team, dist, l, m):
    
    new_dist = {}
    
    for d in dist :
        p = dist[d]
        
        #Team one is in the lead.
        if d > 0:
            new_dist = updateNewDist(new_dist, d+team+1, p*l)
            new_dist = updateNewDist(new_dist, d+team-1, p*m)

        #Teams are tied.
        elif d == 0:
            new_dist = updateNewDist(new_dist, team+1, p*0.5)
            new_dist = updateNewDist(new_dist, team-1, p*0.5)

        #Team 2 is in the lead
        else : #d < 0
            new_dist = updateNewDist(new_dist, d+team+1, p*m)
            new_dist = updateNewDist(new_dist, d+team-1, p*l)
           
    return(new_dist)

            
#Gives the distribution of scores for the input provided.
#pos = Number of pairs of possessions.
#x = percent added/subtracted.
def boringGame(pos, x):
    
    x = x / 100
    
    #Lazy probability
    l = 0.5 - x
    #Motivated probability
    m = 0.5 + x
    
    #Game starts with a tie, 100% of the time
    dist = {0:100}
    
    for pairs in range(pos):
        
        #Team 1's possession.
        dist = updateDist(1, dist, l, m)

        #Team 2's possession.
        dist = updateDist(-1, dist, l, m)

    return(dist)
In [8]:
boringGame(1, 25)[0]
Out[8]:
62.5
In [9]:
boringGame(5, 25)[0]
Out[9]:
50.94718933105469
In [10]:
boringGame(20, 25)[0]
Out[10]:
50.00239344248813
In [2]:
result = boringGame(50, 25)

result[0]
Out[2]:
50.00000012246383
In [3]:
#All Nicks wins.
sum = 0
for d in result.keys():
    if d > 0 :
        sum += result[d]
sum
Out[3]:
12.500000104575726
In [4]:
#All Naughts wins.
sum = 0
for d in result.keys():
    if d < 0 :
        sum += result[d]
sum
Out[4]:
37.49999977296044
In [5]:
#Full Distribution
result
Out[5]:
{100: 1.2446030555722283e-58,
 98: 3.783593288939574e-56,
 96: 5.699037391465234e-54,
 94: 5.670989017004858e-52,
 92: 4.1940298346149474e-50,
 90: 2.4589883915668537e-48,
 88: 1.1906306854551253e-46,
 86: 4.8972250118240815e-45,
 84: 1.7468746449588547e-43,
 82: 5.490272268928038e-42,
 80: 1.539560696349007e-40,
 78: 3.8914021028188567e-39,
 76: 8.941597404058464e-38,
 74: 1.8813152012578095e-36,
 72: 3.647208208670258e-35,
 70: 6.55092681869195e-34,
 68: 1.0955431672130254e-32,
 66: 1.7135323321532182e-31,
 64: 2.5171059696090647e-30,
 62: 3.486320888051493e-29,
 60: 4.570206394934019e-28,
 58: 5.691411470736067e-27,
 56: 6.758151871217328e-26,
 54: 7.680445437020514e-25,
 52: 8.386081808560912e-24,
 50: 8.831975228090831e-23,
 48: 9.008318537631392e-22,
 46: 8.93543078745628e-21,
 44: 8.655319490489902e-20,
 42: 8.22103782590773e-19,
 40: 7.686766539471417e-18,
 38: 7.100554098439418e-17,
 36: 6.500386232707763e-16,
 34: 5.913222050376871e-15,
 32: 5.3560725867911606e-14,
 30: 4.838100248799582e-13,
 28: 4.362924293447098e-12,
 26: 3.9306375026398926e-11,
 24: 3.5393314314529986e-10,
 22: 3.186125777569139e-09,
 20: 2.867796039341199e-08,
 18: 2.581119070668454e-07,
 16: 2.323041561006447e-06,
 14: 2.0907478527241993e-05,
 12: 0.00018816758330187478,
 10: 0.0016935088235666604,
 8: 0.015241579933323314,
 6: 0.1371742163470157,
 4: 1.2345679227313548,
 2: 11.111111188262935,
 0: 50.00000012246383,
 -2: 33.33333325169078,
 -4: 3.70370362505497,
 -6: 0.4115225931974199,
 -8: 0.04572472016779615,
 -10: 0.005080520100383174,
 -12: 0.000564500817749951,
 -14: 6.272188371540047e-05,
 -16: 6.968975553638823e-06,
 -18: 7.742974772086427e-07,
 -20: 8.60245543583173e-08,
 -22: 9.556211190497772e-09,
 -24: 1.0613198784531645e-09,
 -26: 1.178178640541882e-10,
 -28: 1.306837133379678e-11,
 -30: 1.4475075823008613e-12,
 -32: 1.5996251084698157e-13,
 -34: 1.7613686370386107e-14,
 -36: 1.9290807565441203e-15,
 -38: 2.0966783666752261e-16,
 -40: 2.2552251566244762e-17,
 -42: 2.392906162433977e-18,
 -44: 2.495661990841437e-19,
 -46: 2.5486603091448582e-20,
 -48: 2.538580505512008e-21,
 -50: 2.4563893266191e-22,
 -52: 2.2999809366697811e-23,
 -54: 2.0758819165253306e-24,
 -56: 1.7993094304040938e-25,
 -58: 1.4922635205354288e-26,
 -60: 1.1799374212940517e-27,
 -62: 8.863204743574938e-29,
 -64: 6.301876558239856e-30,
 -66: 4.225548730072428e-31,
 -68: 2.6616135525533047e-32,
 -70: 1.5684240604241803e-33,
 -72: 8.607956556193003e-35,
 -74: 4.378467129508291e-36,
 -76: 2.0527890899755762e-37,
 -78: 8.815653638796101e-39,
 -80: 3.442831443861292e-40,
 -82: 1.2123668372109277e-41,
 -84: 3.810412780844016e-43,
 -86: 1.0555449697543561e-44,
 -88: 2.536665579651326e-46,
 -90: 5.1801402913691886e-48,
 -92: 8.738783607849376e-50,
 -94: 1.1690797953982722e-51,
 -96: 1.1627330665766872e-53,
 -98: 7.641862761213482e-56,
 -100: 2.4892061111444567e-58}