Last active
June 20, 2017 09:51
-
-
Save balkian/887c5b163f5359a6a13a7858e7f484d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NEUTRAL = 0 | |
| INFECTED = 1 | |
| class ControlModelM2(BaseBehaviour): | |
| NEUTRAL = 0 | |
| INFECTED = 1 | |
| def step(self, now): | |
| if self.state['id'] == NEUTRAL: | |
| self.neutral_behaviour() | |
| elif self.state['id'] == INFECTED: | |
| self.infected_behaviour() | |
| … | |
| def infected_behaviour(self): | |
| neutral_neighbors = self.get_neighboring_agents(state_id=INFECTED) | |
| for neighbor in neutral_neighbors: | |
| if random.random() < self.prob_infect: | |
| neighbor.state['id'] = INFECTED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment