示例#1
0
def find_dragon(image: Image):
    indices = locate_dragons(image)
    for i in range(4):
        if len(indices) != 0:
            print(f"Breaking because indices = {indices}")
            break
        print(f"Rotating {i+1} times")
        image.rotate()
        indices = locate_dragons(image)

    if len(indices) == 0:
        print(f"Flipping the image")
        image.flip()
        indices = locate_dragons(image)
        for i in range(4):
            if len(indices) != 0:
                print(f"Breaking because indices = {indices}")
                break
            print(f"Rotating again {i + 1} times")
            image.rotate()
            indices = locate_dragons(image)

    filled_image = fill_dragons(image, indices)
    print(image.pretty())

    return calculate_roughness(filled_image)