1
0
mirror of https://github.com/gsi-upm/soil synced 2025-07-05 12:32:21 +00:00
soil/soil/agents/BassModel.py
J. Fernando Sánchez 2869b1e1e6 Clean-up
* Removed old/unnecessary models
* Added a `simulation.{iter_}from_py` method to load simulations from python
files
* Changed tests of examples to run programmatic simulations
* Fixed programmatic examples
2022-11-13 20:31:05 +01:00

31 lines
734 B
Python

from . import FSM, state, default_state
class BassModel(FSM):
"""
Settings:
innovation_prob
imitation_prob
"""
sentimentCorrelation = 0
def step(self):
self.behaviour()
@default_state
@state
def innovation(self):
if self.prob(self.innovation_prob):
self.sentimentCorrelation = 1
return self.aware
else:
aware_neighbors = self.get_neighbors(state_id=self.aware.id)
num_neighbors_aware = len(aware_neighbors)
if self.prob((self.imitation_prob * num_neighbors_aware)):
self.sentimentCorrelation = 1
return self.aware
@state
def aware(self):
self.die()