def infect(self): """The infection routine itself. If not infected, person gets infected. Log is printed to stderr.""" if self.p_infected == False: self.p_infected = True self.p_color = 1 self.p_color_rgba = (1.0, 0.1, 0.1, 1.0) start_action(self.infect_other, delay=0) sys.stderr.write('t=%s %s infected - started %s\n' % (self.sim.now(), self.name, 'self.infect_other'))
def infect(self, for_sure=False): """The infection routine itself. If not infected, person gets infected and speed is set to its half.""" if for_sure or self._random.random() < 0.5: if self.p_infected == False: self.p_infected = True self.p_color = 1 self.p_color_rgba = (1.0, 0.1, 0.1, 1.0) self.p_speed = self.p_speed / 2 start_action(self.infect_other)
def infect(self): """The infection routine itself. If not infected, person gets infected and speed is set to its half. Action infect_other is started.""" if self.p_infected == False: self.p_infected = True self.p_color = 1 self.p_color_rgba = (1.0, 0.1, 0.1, 0.8) self.p_speed = self.p_speed / 2 sys.stderr.write('t=%s person %s got INFECTED\n' % (self.sim.now(), self.p_id)) start_action(self.infect_other)
def __init__(self, *args, **kwargs): """Init the BT-Infect-Wiggler.""" super(BTVirusWiggler, self).__init__(*args, **kwargs) self.p_infected = False #: infected? self.pplInRange = {} #: stores infecting people in range self.p_infecttime = None #: time if infection if 'infected' in kwargs: self.p_color = 1 #: color for playerChamplain self.p_color_rgba = (0.9,0.1,0.1,1.0) #: color for sim_viewer.py self.p_infected = True self.p_infectionTime = self.sim.now() self.p_infectionPlace = self.current_coords() #: coordinates of infection print self.p_infectionTime, self.p_infectionPlace[0], self.p_infectionPlace[1], self.name, self.name start_action(self.infect_other) if 'infectionTime' in kwargs: self.p_infectionTime = kwargs['infectionTime']
def tryinfect(self, infecting_one): """The infection routine itself. If not infected, person gets infected if bad one is in range of 10 to 20m for 15 seconds.""" now = self.sim.now() if infecting_one not in self.pplInRange: # was not in range till now? new = { infecting_one : [1, now]} # remember duration, last time self.pplInRange.update(new) # and store else: # was in range before? old = self.pplInRange[infecting_one] # get old if old[1] < self.sim.now()-1: # if last time was not last tick new = { infecting_one : [1, now] } # reset: remember duration, last time self.pplInRange.update(new) # and store else: # last time was last tick or newer new = { infecting_one : [old[0]+1, now] } # increase duration, update last time self.pplInRange.update(new) # and store if self.pplInRange[infecting_one][0] >= 15: # if infection time is reached self.p_color = 3 self.p_color_rgba = (0.5,0.0,0.5,1.0) self.p_infected = True # I'm infected, infectious in 300s self.p_infectionTime = now # I was infected when self.p_infectionPlace = self.current_coords() # I was infected where print self.p_infectionTime, self.p_infectionPlace[0], self.p_infectionPlace[1], self.name, infecting_one.name start_action(self.infect_other, delay=300) # start being infectious after 300s