Exemple #1
0
def testAutoTurn():
    oldScore = 0
    newTurn = True

    while newTurn == True:
        dice = 10     # initialize by rolling 10 dice, resetting score to 0
        score = 0
        rollOn = True

        while rollOn == True:
            r = fargo.rollResult(dice)
            score += r[0]
            dice = r[1]

            if r[0]==0:             #No score imporvement => lose and turn over.
                score = 0
                print("You lose! Your score is", oldScore)
                rollOn = False
                newTurn = False
                return oldScore     #End the function if lose

            if r[1]==0:             #No dice left => win.
                print("You win! Your score is", score, "... New turn!!!", "\n")
                oldScore += score
                rollOn = False
                newTurn = True      #Call the function again if win.

            if dice !=0:
                print("Your score is ", score,"... You have", r[1], "dice left.")
                if dice<=2 and score>=1000:
                    rollOn = False
                    newTurn = False
                    print("Your score is", score)
                    return(score + oldScore)
Exemple #2
0
def testAutoTurn(diceVeto, scoreOverrule):
    oldScore = 0
    newTurn = True

    while newTurn == True:
        dice = 10     # initialize by rolling 10 dice, resetting score to 0
        score = 0
        rollOn = True

        while rollOn == True:
            r = fargo.rollResult(dice)
            score += r[0]
            dice = r[1]

            if r[0]==0:
                score = 0
                return oldScore

            if r[1]==0:
                oldScore += score
                rollOn = False
                newTurn = True

            if dice !=0:
                if dice<=diceVeto and score>=scoreOverrule:
                    rollOn = False
                    newTurn = False
                    return(score + oldScore)
Exemple #3
0
def createExpValDict(nRolls):
    resultDict = {}
    for i in range(1,11,1):
        total = 0
        for j in range(nRolls):
            score = fargo.rollResult(i)[0]
            total += score
        resultDict[i]=total/nRolls
    return resultDict
Exemple #4
0
def createp_contDict(nRolls):
    resultDict = {9:1, 10:1}
    for i in range(1,9,1):
        nCont = 0
        for j in range(nRolls):
            score = fargo.rollResult(i)[0]
            if score > 1:
                nCont+=1
        resultDict[i]=nCont/nRolls
    return resultDict
Exemple #5
0
def allOrNothing():
    dice = 10       # initialize by rolling 10 dice
    cont = 1

    while cont !=0:
        r = fargo.rollResult(dice)
        dice = r[1]

        if r[0]==0:             #No score imporvement => lose and turn over.
            return 0            #End the function if lose

        if r[1]==0:             #No dice left => win, end function
            return 1