simulation.set_cell(10, 10, (255, 0, 0)) simulation.remove_cell(10, 10) # Red is Infected, Green is Recovered, Blue is susceptible, Cyan is dead colors = [(200, 0, 0), (0, 200, 0), (0, 0, 200), (0, 255, 255)] for m in range(0, 60): for p in range(0, 40): if random() > 0.875: simulation.set_cell(m, p, colors[randint(1, 2)]) 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
def Infected(cell, InfectionPercent): if randint(0,100)<=InfectionPercent: sim.set_cell(cell[0], cell[1], SIRD[1]) def DeathChance(cell, Death): if randint(0,1000)<=(Death*10): sim.set_cell(cell[0], cell[1], SIRD[3]) else: 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])