1
0
mirror of https://github.com/gsi-upm/soil synced 2025-04-25 06:09:05 +00:00
soil/soil/agents/BassModel.py
2021-10-14 17:37:06 +02:00

32 lines
772 B
Python

import random
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 random.random() < self.innovation_prob:
self.sentimentCorrelation = 1
return self.aware
else:
aware_neighbors = self.get_neighboring_agents(state_id=self.aware.id)
num_neighbors_aware = len(aware_neighbors)
if random.random() < (self['imitation_prob']*num_neighbors_aware):
self.sentimentCorrelation = 1
return self.aware
@state
def aware(self):
self.die()