mirror of
				https://github.com/balkian/gists.git
				synced 2025-10-31 07:38:27 +00:00 
			
		
		
		
	This commit is contained in:
		
							
								
								
									
										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 | ||||
		Reference in New Issue
	
	Block a user