Пример #1
0
def botRightPress():
    global gameOver
    if gameOver == 0:
        global turn
        global botRightComp
        global AIturn
        global Xwin
        global Owin
        global aiSkill
        if botRightComp == 0:
            if turn == 0:
                place[8] = 1
                turn = 1
                BotRight.configure(text="X")
            else:
                turn = 0
                place[8] = 2
                BotRight.configure(text="O")
            botRightComp = 1
            L = checkWin(place, AIturn, End, Xwin, Owin, turn, aiSkill)
            Xwin = Xwin + L[0]
            Owin = Owin + L[1]
            gameOver = L[2]
            if AIturn % 2 == 0:
                AIturn = AIturn + 1
                AI(aiSkill, place, turn, AIturn)

            else:
                AIturn = AIturn + 1
        else:
            print("Already Set Box")
        return place
Пример #2
0
def topLeftPress():
    global gameOver  #No moves can be made if game is over.
    if gameOver == 0:
        global turn  #These are required to call the function in the checkWin.py
        global topLeftComp
        global AIturn
        global Xwin
        global Owin
        global aiSkill
        if topLeftComp == 0:  #check if space is filled
            if turn == 0:
                place[0] = 1
                turn = 1
                TopLeft.configure(text=("X"))
            else:
                turn = 0
                place[0] = 2
                TopLeft.configure(text="O")
            topLeftComp = 1
            L = checkWin(place, AIturn, End, Xwin, Owin, turn, aiSkill)
            Xwin = Xwin + L[0]
            Owin = Owin + L[1]
            gameOver = L[2]
            if AIturn % 2 == 0:  #Call AI turn every two turns
                AIturn = AIturn + 1
                AI(aiSkill, place, turn, AIturn)

            else:
                AIturn = AIturn + 1
        else:
            print("Already Set Box")
        return place