Пример #1
0
done = False

# set up grid for the time that each cell has been infected for
infectedlife = []
for n in range(60):
    infectedlife.append([0] * 40)
while not done:
    done = simulation.process_events()
    simulation.update()
    for cell in simulation.cells:
        # create new infected
        # print(simulation.cells[cell])
        if simulation.cells[cell] == (0, 0, 200):
            infectchance = 0
            # 1 square away
            onesquare = simulation.get_surroundings(cell[0], cell[1], 1)
            onep = 0
            print(onesquare)
            for r in onesquare:
                for t in r:
                    if t == (200, 0, 0):
                        print(t)
                        onep += 1
            infectchance += 0.25 * onep
            # 2 squares away
            twosquare = simulation.get_surroundings(cell[0], cell[1], 2)
            twop = 0
            for r in twosquare:
                for t in r:
                    if t == (200, 0, 0):
                        twop += 1
Пример #2
0
        if s[line][2][0] == 200:
            rate6 += 25
    if type(s[line][4]) == tuple:
        if s[line][4][0] == 200:
            rate6 += 25
    return rate6


info = {}
for cell in simulation.cells:
    info[cell[0], cell[1]] = [simulation.cells[cell], 0]

for i in range(time):
    for cell in simulation.cells:
        rate = 0
        s = simulation.get_surroundings(cell[0], cell[1], 3)
        rate = rate + three_blocks_first_last(0) + three_blocks_first_last(
            6) + three_blocks_zero_six(1) + three_blocks_zero_six(
                2) + three_blocks_zero_six(3) + three_blocks_zero_six(
                    4) + three_blocks_zero_six(5) + two_blocks_first_last(
                        1) + two_blocks_first_last(5) + two_blocks_one_five(
                            2) + two_blocks_one_five(3) + two_blocks_one_five(
                                4) + adjacent_first_last(
                                    2) + adjacent_first_last(
                                        4) + adjacent_two_four(3)
        if rate > 97:
            rate = 97
        if randint(0, 100) <= rate:
            simulation.cells[cell] = (200, 0, 0)

        if info[cell[0], cell[1]][0][0] == 200: