2017-06-20 09:51:56 +00:00
|
|
|
NEUTRAL = 0
|
|
|
|
INFECTED = 1
|
|
|
|
|
2017-06-20 09:49:08 +00:00
|
|
|
class ControlModelM2(BaseBehaviour):
|
|
|
|
NEUTRAL = 0
|
|
|
|
INFECTED = 1
|
|
|
|
def step(self, now):
|
2017-06-20 09:51:56 +00:00
|
|
|
if self.state['id'] == NEUTRAL:
|
2017-06-20 09:49:08 +00:00
|
|
|
self.neutral_behaviour()
|
2017-06-20 09:51:56 +00:00
|
|
|
elif self.state['id'] == INFECTED:
|
2017-06-20 09:49:08 +00:00
|
|
|
self.infected_behaviour()
|
|
|
|
…
|
|
|
|
def infected_behaviour(self):
|
2017-06-20 09:51:56 +00:00
|
|
|
neutral_neighbors = self.get_neighboring_agents(state_id=INFECTED)
|
2017-06-20 09:49:08 +00:00
|
|
|
for neighbor in neutral_neighbors:
|
|
|
|
if random.random() < self.prob_infect:
|
2017-06-20 09:51:56 +00:00
|
|
|
neighbor.state['id'] = INFECTED
|