def main():
    width = int(input('Enter the width: '))
    height = int(input('Enter the height: '))
    chance = 40
    count = 5
    iterations = int(input('Enter the number of regular iterations: '))
    pillarIterations = int(input('Enter the number of pillar-generating iterations: '))
    floodTries = 5
    goalPercentage = 30
    grid = makeGrid(width, height)
    print('\nRandomly populated grid:')
    grid = populateGrid(grid, chance)
    printGrid(grid, '# ', '· ')
    for i in range(pillarIterations):
        print('{0} iteration(s) of automata with pillars:'.format((i + 1)))
        grid = automataIteration(grid, count, 1)
        printGrid(grid, '# ', '· ')
    for i in range(iterations):
        print('{0} iteration(s) of regular automata:'.format((i + 1)))
        grid = automataIteration(grid, count, 0)
        printGrid(grid, '# ', '· ')
    print('\nAfter flood algorithm to find the biggest cave:')
    (grid, percentage) = floodFindEmpty(grid, floodTries, goalPercentage)
    if (percentage < goalPercentage):
        print('Failed to produce a big enough cave after {0} tries...'.format(floodTries))
    else:
        print('Percentage of open space: {0}%'.format(percentage))
        printGrid(grid, '# ', '· ')
    print('')
    main()
def main():
    width = int(input('Enter the width: '))
    height = int(input('Enter the height: '))
    chance = 40
    count = 5
    iterations = int(input('Enter the number of regular iterations: '))
    pillarIterations = int(input('Enter the number of pillar-generating iterations: '))
    floodTries = 5
    goalPercentage = 30
    grid = makeGrid(width, height)
    print('\nRandomly populated grid:')
    grid = populateGrid(grid, chance)
    printGrid(grid, '# ', '· ')
    for i in range(pillarIterations):
        print('{0} iteration(s) of automata with pillars:'.format((i + 1)))
        grid = automataIteration(grid, count, 1)
        printGrid(grid, '# ', '· ')
    for i in range(iterations):
        print('{0} iteration(s) of regular automata:'.format((i + 1)))
        grid = automataIteration(grid, count, 0)
        printGrid(grid, '# ', '· ')
    print('\nAfter flood algorithm to find the biggest cave:')
    (grid, percentage) = floodFindEmpty(grid, floodTries, goalPercentage)
    if (percentage < goalPercentage):
        print('Failed to produce a big enough cave after {0} tries...'.format(floodTries))
    else:
        print('Percentage of open space: {0}%'.format(percentage))
        printGrid(grid, '# ', '· ')
    print()
    main()