mirror of
https://github.com/balkian/gists.git
synced 2024-11-24 02:12:29 +00:00
This commit is contained in:
parent
2798757188
commit
b259496b22
11
prueba.py
11
prueba.py
@ -1,14 +1,17 @@
|
|||||||
|
NEUTRAL = 0
|
||||||
|
INFECTED = 1
|
||||||
|
|
||||||
class ControlModelM2(BaseBehaviour):
|
class ControlModelM2(BaseBehaviour):
|
||||||
NEUTRAL = 0
|
NEUTRAL = 0
|
||||||
INFECTED = 1
|
INFECTED = 1
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
if self.state['id'] == self.NEUTRAL: #Neutral
|
if self.state['id'] == NEUTRAL:
|
||||||
self.neutral_behaviour()
|
self.neutral_behaviour()
|
||||||
elif self.state['id'] == self.INFECTED: #Infected
|
elif self.state['id'] == INFECTED:
|
||||||
self.infected_behaviour()
|
self.infected_behaviour()
|
||||||
…
|
…
|
||||||
def infected_behaviour(self):
|
def infected_behaviour(self):
|
||||||
neutral_neighbors = self.get_neighboring_agents(state_id=self.NEUTRAL)
|
neutral_neighbors = self.get_neighboring_agents(state_id=INFECTED)
|
||||||
for neighbor in neutral_neighbors:
|
for neighbor in neutral_neighbors:
|
||||||
if random.random() < self.prob_infect:
|
if random.random() < self.prob_infect:
|
||||||
neighbor.state['id'] = self.INFECTED
|
neighbor.state['id'] = INFECTED
|
||||||
|
Loading…
Reference in New Issue
Block a user