Esempio n. 1
0
def main():
    numbers = read_numbers()
    three = numbers[3][0]
    # for i in three:
    #     print(i)

    cnt = 0
    for i, elem in enumerate(three):
        for j, e in enumerate(elem):
            three[i][j] = cnt
            cnt += 1

    place = [[1, 0, 0, 0, 0],
             [0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0]]

    # q = hello(three, place)
    # print("size: ", len(q), len(q[0]))

    for i, elem in enumerate(place):
        for j, e in enumerate(elem):
            place[i][j] = 1
            q = hello(three, place)
            print("size: ", len(q), len(q[0]))
            out_matrix(place)
            out_matrix(q)
            print()
            print()
            place[i][j] = 0
Esempio n. 2
0
def main():
    numbers = read_numbers()
    three = numbers[3][0]

    place = [[0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0],
             [0, 0, 1, 0, 0],
             [0, 0, 0, 0, 0]]
    for i in three:
        print(i)
    print()

    BUBBLE_SIZE = 7

    q = hello(three, place)
    print("SIZE: ", len(q), len(q[0]))
    for i in q:
        print(i)
    bubbled_place = make_bubble(place, BUBBLE_SIZE)
    out_matrix(bubbled_place)
    out_matrix(zip_bubbled_data(bubbled_place, BUBBLE_SIZE))

    # важно чтобы id клеток разных регионов не пересекались!!!
    r = Region(len(merge_input([make_bubble(place, BUBBLE_SIZE), hello(three, place)])), 5, 0)

    for step in range(200):
        s = 0
        x = -1
        y = -1
        for i, I in enumerate(place):
            for j, J in enumerate(I):
                if place[i][j] == 1:
                    x, y = i, j
                    break

        print("-----" * 10)
        for i in place:
            print(i)
        print("-----" * 10)
        for i, I in enumerate(place):
            for j, J in enumerate(I):
                place[i][j] = 0

        if (x == -1 and y == -1) or step < 10:
            while 1:
                x = randrange(len(place))
                y = randrange(len(place))
                place[x][y] = 1
                if get_sum(hello(three, place)):
                    break
                place[x][y] = 0
        else:
            place[x][y] = 1
        r.step_forward(merge_input([make_bubble(place, BUBBLE_SIZE), hello(three, place)]))

        r.out_prediction()
        new_place = zip_bubbled_data(do_cut(r.get_binary_prediction(), len(make_bubble(place, BUBBLE_SIZE))),
                                     BUBBLE_SIZE)
        place = new_place