## d20 Fixed Board Dice Game

import random

## define variables

outcomes = 6
roll = 0

twoTwelveWin = 0                     ## Variables for counting game wins
threeElevenWin = 0
fourTenWin = 0
fiveNineWin = 0
sixEightWin = 0
sevenWin = 0

trials = int(input("Number of Trials: "))         ## Number of Trials

scale = int(input("Proportionality scale: "))     ## Scale of the board proportionality

k = 0

for k in range(0, trials):

    twoTwelve = 0  ## Variables for counting game wins
    threeEleven = 0
    fourTen = 0
    fiveNine = 0
    sixEight = 0
    seven = 0

    end = 0

    while (end == 0):  ##  Optional output commands are marked as comment lines

        roll = (random.randint(1, 6) + random.randint(1, 6))
        ## print('Roll ', k, ' = ', roll)
        if (roll == 2) or (roll == 12):
            twoTwelve = twoTwelve + 1
        elif (roll == 3) or (roll == 11):
            threeEleven = threeEleven + 1
        elif (roll == 4) or (roll == 10):
            fourTen = fourTen + 1
        elif (roll == 5) or (roll == 9):
            fiveNine = fiveNine + 1
        elif (roll == 6) or (roll == 8):
            sixEight = sixEight + 1
        elif (roll == 7):
            seven = seven + 1


        if (twoTwelve == 2*scale):
            twoTwelveWin = twoTwelveWin + 1
            ## print('Trial #', k, ', Two/Sxiteen wins.')
            end = 1
        elif (threeEleven == 4*scale):
            threeElevenWin = threeElevenWin + 1
            ## print('Trial #', k, ', Three/Fifteen wins.')
            end = 1
        elif (fourTen == 6*scale):
            fourTenWin = fourTenWin + 1
            ## print('Trial #', k, ', Four/Fourteen wins.')
            end = 1
        elif (fiveNine == 8*scale):
            fiveNineWin = fiveNineWin + 1
            ## print('Trial #', k, ', Five/Nine wins.')
            end = 1
        elif (sixEight == 10*scale):
            sixEightWin = sixEightWin + 1
            ## print('Trial #', k, ', Six/Eight wins.')
            end = 1
        elif (seven == 6*scale):
            sevenWin = sevenWin + 1
            ## print('Trial #', k, ', Seven/Eleven wins.')
            end = 1



print('Fixed Board, d6, scale of ',scale,' and ',trials,' trials:')
print(' # # # # # # # ')
print('Two/Twelve won ', twoTwelveWin, 'times for ', (100 * twoTwelveWin) / trials, '%.')
print('Three/Thirty-Nine won ', threeElevenWin, 'times for ', (100 * threeElevenWin) / trials, '%.')
print('Four/Thirty-eight won ', fourTenWin, 'times for ', (100 * fourTenWin) / trials, '%.')
print('Five/Thirty-seven won ', fiveNineWin, 'times for ', (100 * fiveNineWin) / trials, '%.')
print('Six/Thirty-six won ', sixEightWin, 'times for ', (100 * sixEightWin) / trials, '%.')
print('Seven/Thirty-five won ', sevenWin, 'times for ', (100 * sevenWin) / trials, '%.')

fairSharePercent = 1/outcomes
print('Equal percent is', fairSharePercent,'%')
variance = (((((twoTwelveWin) / trials)-fairSharePercent)**2)+((((threeElevenWin) / trials)-fairSharePercent)**2)
            +((((fourTenWin) / trials)-fairSharePercent)**2)+((((fiveNineWin) / trials)-fairSharePercent)**2)
            +((((sixEightWin) / trials)-fairSharePercent)**2)+((((sevenWin) / trials)-fairSharePercent)**2) )/ (outcomes - 1)
print('Game variance is ', variance)