Пример #1
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Cell[1-9 or q to quit]: ")
        if choice.lower()[0] == 'q':
            save = input("Save game before quitting?[y/n] ")
            if save.lower()[0] == 'y':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice)-1
                if not (0 <= cell <= 8):  # check range
                    raise ValueError
            except ValueError:
                print("Choose a number between 1 and 9 or 'q' to quit ")
                continue

            try:
                result = oxo_logic.userMove(game,cell)
            except ValueError:
                print("Choose an empty cell")
                continue
            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                print("Its a draw")                
            else:
                printGame(game)
                print("Winner is", result, '\n')
Пример #2
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Cell[1-9 or q to quit]: ")
        if choice.lower()[0] == 'q':
            save = mb.askyesno("Save game","Save game before quitting?")
            if save:
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice)-1
                if not (0 <= cell <= 8):
                    raise ValueError
            except ValueError:
                print("Choose a number or 'q' to quit")
                continue

            try:
                result = oxo_logic.userMove(game,cell)
            except ValueError:
                mb.showerror("Invalid cell", "Choose an empty cell")
                continue
            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                mb.showinfo("Result", "It's a draw")
            else:
                printGame(game)
                mb.showinfo("Result", "Winner is {}".format(result))
Пример #3
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Celda[1-9 o q para quitar]: ")
        if choice.lower()[0] == 'q':
            saves = input("Guardar partida antes de abandonar??[S/N] ")
            if save.lower()[0] == 'S':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):
                    raise ValueError
            except ValueError:
                print("Escoje un numero entre 1 o 9 'q' para quitar ")
                continue

            try:
                result = oxo_logic.userMove(game, cell)
            except ValueError:
                print("Elige una celda vacia")
                continue

            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                print("Es un empate")
            else:
                printGame(game)
                print("El ganador es", result, '\n')
Пример #4
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Quadrante [1-9 ou s para sair]: ")
        if choice.lower()[0] == 's':
            save = input("Salvar o jogo antes de sair? [s/n] ")
            if save.lower()[0] == 's':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):
                    raise ValueError
            except ValueError:
                print("Escolha um número entre 1 e 9 ou 's' para sair.")
                continue

            try:
                result = oxo_logic.userMove(game, cell)
            except ValueError:
                print("Escolha um quadrante vazio.")
                continue

            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                print("Deu empate.")
            else:
                printGame(game)
                print("O vencedor foi ", result, "\n")
Пример #5
0
def playGame(game):
    result = ''
    while not result:
        printGame(game)
        choice = input('Cell[1-9 or q to quit]: ')
        if choice.lower()[0] == 'q':
            save = mb.askyesno("Save game", "Save game before quitting?")
            if save:
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
            	cell = int(choice) - 1
            	if not (0 <= cell <= 8):
            		raise ValueError
            except ValueError:
                print('Choose a number between 1 and 9 or q to quit')
                continue

            try:
                result = oxo_logic.userMove(game, cell)
            except ValueError:
                mb.showerror("Invalid cell", "Choose an empty cell")
                continue
            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                mb.showinfo("Result", "It's a draw")
                print("It's a draw")
            else:
                printGame(game)
                mb.showinfo("Result", "Winner is {}".format(result))
Пример #6
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Cell[1-9 or q to quit]: ")
        if choice.lower()[0] == 'q':
            save = input("Save game before quitting?[y/n] ")
            if save.lower()[0] == 'y':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):  # check range
                    raise ValueError
            except ValueError:
                print("Choose a number between 1 and 9 or 'q' to quit ")
                continue

            try:
                result = oxo_logic.userMove(game, cell)
            except ValueError:
                print("Choose an empty cell")
                continue
            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                print("Its a draw")
            else:
                printGame(game)
                print("Winner is", result, '\n')
Пример #7
0
def playGame(game):
    result =""
    printGrid()
    while not result:
        printGame(game)
        choice = raw_input('Cell[1-9 or q to quit]:')
        if choice.lower()[0] == 'q':
            save = raw_input('save game before quitting? [y/n]?')
            if save.lower()[0] =='y':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice)-1
                if not (0 <= cell <= 8): #check range
                    raise ValueError
            except ValueError:
                print "Choose a number between 1 and 9 or 'q' to quit"
                continue
        try: 
            result = oxo_logic.userMove(game,cell)
        except ValueError:
            print ("Choose any empty cell")
            continue
        if not result:
            result = oxo_logic.computerMove(game)
        if not result:
            continue
        elif result == 'D':
            printGame(game)
            print "It's a draw"
        else:
            printGame(game)
            mb.showinfo("Winner", result)  
            print ("Winner is ", result)
Пример #8
0
def playGame(game):
    result = ""
    while not result:
        printGame(game)
        choice = input("Cell [1-9 or q to quit]: ")
        if choice.lower()[0] == 'q':
            save = input('Save game before quitting? [y/n] ')
            if save.lower()[0] == 'y':
                oxo_logic.saveGame(game)
            quitGame()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):
                    raise ValueError
            except ValueError:
                print('Choose a number between 1 and 9 or "q" to quit.')
                continue

            try:
                result = oxo_logic.userMove(game, cell)
            except ValueError:
                print('Choose an empty cell')
                continue
            if not result:
                result = oxo_logic.computerMove(game)
            if not result:
                continue
            elif result == 'D':
                printGame(game)
                print('Its a draw')
            else:
                printGame(game)
                print('Winner is', result, "\n")
Пример #9
0
def playGame(game):
    result = ""
    printGrid()
    while not result:
        printGame(game)
        choice = raw_input('Cell[1-9 or q to quit]:')
        if choice.lower()[0] == 'q':
            save = raw_input('save game before quitting? [y/n]?')
            if save.lower()[0] == 'y':
                oxo_logic.saveGame(game)
            quit()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):  #check range
                    raise ValueError
            except ValueError:
                print "Choose a number between 1 and 9 or 'q' to quit"
                continue
        try:
            result = oxo_logic.userMove(game, cell)
        except ValueError:
            print("Choose any empty cell")
            continue
        if not result:
            result = oxo_logic.computerMove(game)
        if not result:
            continue
        elif result == 'D':
            printGame(game)
            print "It's a draw"
        else:
            printGame(game)
            mb.showinfo("Winner", result)
            print("Winner is ", result)
Пример #10
0
def evSave():
    game = cells2game()
    oxo_logic.saveGame(game)
Пример #11
0
def evSave():
    game = cells2game()
    oxo_logic.saveGame(game)