mirror of
https://github.com/balkian/gists.git
synced 2024-12-22 22:38:12 +00:00
This commit is contained in:
commit
afebf97965
14
prueba.py
Normal file
14
prueba.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user