commit afebf979653467c2a342c7dc9bd33d12bfb1b23d Author: J. Fernando Sánchez Date: Tue Jun 20 11:49:08 2017 +0200 diff --git a/prueba.py b/prueba.py new file mode 100644 index 0000000..b06a3fa --- /dev/null +++ b/prueba.py @@ -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