return False def Recovery(cell, RecoveryRate): if randint(0,1000)<=(RecoveryRate*10): sim.set_cell(cell[0], cell[1], SIRD[2]) while not done: done = sim.process_events() if setup==False: for i in range(0, 300): sim.set_cell(randint(0, 60), randint(0,40), SIRD[randint(0,1)]) setup=True if time!=0: for cell in sim.cells: InfectionPercent=0 color = sim.get_cell(cell[0], cell[1]) if color==SIRD[0]: InfectionPercent=sweep(cell, InfectionPercent) Infected(cell, InfectionPercent) time-=1 elif time==0: for cell in sim.cells: color = sim.get_cell(cell[0], cell[1]) if color==SIRD[1]: Dead = DeathChance(cell, Death) if Dead==False: Recovery(cell, RecoveryRate) time=3 sim.update()
from gridworld import GridWorld from random import randint simulation = GridWorld(100, 80, 10) color = simulation.get_cell(10, 10) colors = [(200, 0, 0), (0, 200, 0), (0, 0, 200)] for i in range(1000): simulation.set_cell(randint(0, 100), randint(0, 80), colors[randint(0, 2)]) time = 100 def three_blocks_first_last(line): rate1 = 0 for item in s[line]: if type(item) == tuple: if item[0] == 200: rate1 += 2 return rate1 def three_blocks_zero_six(line): rate2 = 0 if type(s[line][0]) == tuple: if s[line][0][0] == 200: rate2 += 2 if type(s[line][6]) == tuple: if s[line][6][0] == 200: rate2 += 2