def checkLife(self): """ Check if the human dies because of malaria """ # If the infection is deadly, check if it's time to die already if self.fatalInfection == True and decisionLogarithmic((self.infectedOn/ float(self.config['death-delay']))): self.mother(4) return True # If access to good medicine, cure is short. Check if cured already elif self.medicine == True and decisionLogarithmic((self.infectedOn / float(self.config['cure-medicine']))): self.infectedOn = 0 self.status = 0 self.mother(3) self.checkImmune() # If no access to good medicine, check if cured elif decisionLogarithmic((self.infectedOn/float(self.config['cure']))): self.infectedOn = 0 self.status = 0 self.mother(3) self.checkImmune() # Increase the time already infected else: self.infectedOn += 1
def step(self, maxX, maxY, t): """ Move the mosquito to a new place. Return tuple. """ # If still an egg if self.egg == True: # Check if a new mosquito must be born if self.age > 5 and decisionLogarithmic(self.config['mosq-egg-time']/self.age) == True: self.age = 1 self.egg = False else: self.age += 1 return (self.x, self.y) else: # If already moved this T, stay in this cell if self.t >= t: return (self.x, self.y) else: # find new location if it is the previous block while (self.prevX == self.x and self.prevY == self.y): # move horizontal if staysbetween borders if np.random.randint(2) == 0: newX = self.x + np.random.randint(-1,2) if 0 <= newX < maxX: self.x = newX else: # move veritcal if it stays between borders newY = self.y + np.random.randint(-1,2) if 0 <= newY < maxY: self.y = newY #print "previous xy:",self.prevX , ",", self.prevY, " new:",self.x,",",self.y # safe previous direction self.prevX = self.x self.prevY = self.y self.t = t self.age += 1 # return tuple of new location return (self.x, self.y)
def checkDeath(self,maxAge): # If mosquito dies False if decisionLogarithmic(self.age / float(maxAge)): return True return False