From b259496b2279a15887ceff85cab75a5072845905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 20 Jun 2017 11:51:56 +0200 Subject: [PATCH] --- prueba.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/prueba.py b/prueba.py index cc56567..2357a26 100644 --- a/prueba.py +++ b/prueba.py @@ -1,14 +1,17 @@ +NEUTRAL = 0 +INFECTED = 1 + class ControlModelM2(BaseBehaviour): NEUTRAL = 0 INFECTED = 1 def step(self, now): - if self.state['id'] == self.NEUTRAL: #Neutral + if self.state['id'] == NEUTRAL: self.neutral_behaviour() - elif self.state['id'] == self.INFECTED: #Infected + elif self.state['id'] == INFECTED: self.infected_behaviour() … def infected_behaviour(self): - neutral_neighbors = self.get_neighboring_agents(state_id=self.NEUTRAL) + neutral_neighbors = self.get_neighboring_agents(state_id=INFECTED) for neighbor in neutral_neighbors: if random.random() < self.prob_infect: - neighbor.state['id'] = self.INFECTED + neighbor.state['id'] = INFECTED