def devourHumans(self,mosquito): """ eat a human if there is one and the is mosquito hungry """ config = self.config # check if there is a human to eat when hungry if self.human != None and mosquito.hungry == 1: # Check the consequences of the bite to the human and the mosquito self.human.humanStung(mosquito, self.config) #print "human stung" # if not hungry it is pregnant, check if its time to lay eggs elif mosquito.hungry == 0: # increment oviposition if it is not yet time to lay eggs if mosquito.oviposition != config['mosq-oviposition']: mosquito.oviposition += 1 # lay the eggs after x days else: append = self.mosquitos.append for x in xrange(0, config['mosq-eggs']): # Check if the egg will survive if decision(config['mosq-eggs-survive']) == True: append(m.mosquito(self.x, self.y, mosquito.t, 0, 1, 1, self.config)) #print "I laid some eggs, now:", len(self.mosquitos) # it has digested the blood and dropped the eggs, now it is hungry mosquito.oviposition = 0 mosquito.hungry = 1
def addMosquitos(self): """ Add the mosquitos to the grid, there can be humans and mosquitos on the same field and even multiple mosquitos on one field. """ # Get the numbers of mosquitos in the initial state popMosq = int(self.config["pop-mosq"]) # Generate for each mosquito if it's infected or not and if it's hungry # in the initial state. Based on the initial distribution. infected = (np.random.rand(popMosq) < self.config["init-distr-mosq"]).astype(int) hungry = (np.random.rand(popMosq) < self.config["init-hungry-mosq"]).astype(int) egg = (np.random.rand(popMosq) < self.config["init-egg"]).astype(int) ovi = (np.random.rand(popMosq) < self.config["init-ovi"]).astype(int) t = self.t randint = np.random.randint maxAge = self.config["mosq-max-age"] for i in xrange(1, popMosq - 1): (x, y) = self.getCoordinates() self.grid[x][y].flyIn( m.mosquito(x, y, t, infected[i], hungry[i], randint(1, maxAge), self.config, ovi=ovi[i], egg=egg[i]) )