From afebf979653467c2a342c7dc9bd33d12bfb1b23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 20 Jun 2017 11:49:08 +0200 Subject: [PATCH] --- prueba.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 prueba.py 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