1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-21 09:12:29 +00:00
gists/Modelos Soil de prueba/prueba.py
J. Fernando Sánchez f48bab94dd Move files
2021-10-30 15:23:01 +02:00

18 lines
488 B
Python

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