def moran_cultural(network):
"""Generalized cultural Moran process.
At eachtime step, an individual is chosen to receive information from
another individual. Nobody dies, but perhaps their ideas do.
"""
if not network.transmissions(): # first step, replacer is a source
replacer = random.choice(network.nodes(type=Source))
replacer.transmit()
else:
replacer = random.choice(network.nodes(type=Agent))
replaced = random.choice(
replacer.neighbors(direction="to", type=Agent))
from operator import attrgetter
replacer.transmit(
what=max(replacer.infos(), key=attrgetter('creation_time')),
to_whom=replaced)
评论列表
文章目录