Exemplo n.º 1
0
def main(turn, symbol_player, symbol_computer, board):
    while True:
        if turn == 'player':
            if False:
                validMovesBoard = getBoard_ValidMoves(board, symbol_player)
                print_board(validMovesBoard)
            else:
                print_board(board)

            show_scores(board)
            print("\nIt is {}'s turn, {} is '{}'.".format(
                turn, turn, symbol_player))
            move = Move.MakeMove(board, symbol_player).every_move()
            print('Your move is at {}.'.format(tell_move(move)))
            Move.MakeMove(board,
                          symbol_player).make_move_for_board(move[0], move[1])

            if Move.MakeMove(board,
                             symbol_computer).Flip_pieces(move[0],
                                                          move[1]) == []:
                turn = change_turn(turn)
            else:
                turn = change_turn(turn)

        else:
            if False:
                validMovesBoard = getBoard_ValidMoves(board, symbol_computer)
                print_board(validMovesBoard)
            else:
                print_board(board)

            show_scores(board)
            print("\nIt is {}'s turn, {} is '{}'.".format(
                turn, turn, symbol_computer))
            move = Move.MakeMove(board, symbol_computer).every_move()
            print('Your move is at {}.'.format(tell_move(move)))
            Move.MakeMove(board, symbol_computer).make_move_for_board(
                move[0], move[1])
            if Move.MakeMove(board,
                             symbol_computer).Flip_pieces(move[0],
                                                          move[1]) == []:
                turn = change_turn(turn)
            else:
                turn = change_turn(turn)
    print_board(board)
    scores = show_scores(board)
    who_won(scores)
def main(turn, symbol_player, symbol_computer, board):
    '''Game function. '''
    while True:
        if turn == 'player':
            if False:
                validMovesBoard = getBoard_ValidMoves(board, symbol_player)
                print_board(validMovesBoard)
            else:
                print_board(board)

            scores = show_scores(board)
            print('Player has {} points and computer has {} points.'.format(
                scores[0], scores[1]))
            print("\nIt is {}'s turn, {} is '{}'.".format(
                turn, turn, symbol_player))
            move = every_move(board, symbol_player)
            print('Your move is at {}.'.format(tell_move(move)))
            Move.MakeMove(board,
                          symbol_player).make_move_for_board(move[0], move[1])

            if check_score(show_scores(board)) != 36:
                if Move.MakeMove(board, symbol_computer).Flip_pieces() == []:
                    print(
                        "!!Computer has no where to move; it's player's turn!!"
                    )
                    turn = 'player'
                else:
                    turn = 'computer'
            else:
                break

        else:
            if False:
                validMovesBoard = getBoard_ValidMoves(board, symbol_computer)
                print_board(validMovesBoard)
            else:
                print_board(board)

            scores = show_scores(board)
            print('Player has {} points and computer has {} points.'.format(
                scores[0], scores[1]))
            print("\nIt is {}'s turn, {} is '{}'.".format(
                turn, turn, symbol_computer))
            move = every_move(board, symbol_computer)
            print('Your move is at {}.'.format(tell_move(move)))
            Move.MakeMove(board, symbol_computer).make_move_for_board(
                move[0], move[1])

            if check_score(show_scores(board)) != 36:
                if Move.MakeMove(board, symbol_player).Flip_pieces() == []:
                    print(
                        "!!Player has no where to move; it's computer's turn!!"
                    )
                    turn = 'computer'
                else:
                    turn = 'player'
            else:
                break

    print_board(board)
    scores = show_scores(board)
    print('Player has {} points and computer has {} points.'.format(
        scores[0], scores[1]))
    who_won(scores)