1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-22 01:32:29 +00:00
This commit is contained in:
J. Fernando Sánchez 2017-06-20 11:49:08 +02:00 committed by GitHub
commit afebf97965

14
prueba.py Normal file
View File

@ -0,0 +1,14 @@
class ControlModelM2(BaseBehaviour):
NEUTRAL = 0
INFECTED = 1
def step(self, now):
if self.state['id'] == self.NEUTRAL: #Neutral
self.neutral_behaviour()
elif self.state['id'] == self.INFECTED: #Infected
self.infected_behaviour()
def infected_behaviour(self):
neutral_neighbors = self.get_neighboring_agents(state_id=0)
for neighbor in neutral_neighbors:
if random.random() < self.prob_infect:
neighbor.state['id'] = self.INFECTED