mirror of
https://github.com/gsi-upm/soil
synced 2025-07-05 12:32:21 +00:00
* 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
31 lines
734 B
Python
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() |