2023-04-14 17:41:24 +00:00
|
|
|
from soil import Environment, Simulation, CounterModel, report
|
|
|
|
|
|
|
|
|
|
|
|
# Get directory path for current file
|
|
|
|
import os, sys, inspect
|
|
|
|
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
2023-04-09 02:19:24 +00:00
|
|
|
|
|
|
|
class TorvaldsEnv(Environment):
|
|
|
|
|
|
|
|
def init(self):
|
2023-04-14 17:41:24 +00:00
|
|
|
self.create_network(path=os.path.join(currentdir, 'torvalds.edgelist'))
|
2023-04-09 02:19:24 +00:00
|
|
|
self.populate_network(CounterModel, skill_level='beginner')
|
2023-04-14 17:41:24 +00:00
|
|
|
self.agent(node_id="Torvalds").skill_level = 'God'
|
|
|
|
self.agent(node_id="balkian").skill_level = 'developer'
|
|
|
|
self.add_agent_reporter("times")
|
2023-04-09 02:19:24 +00:00
|
|
|
|
2023-04-14 17:41:24 +00:00
|
|
|
@report
|
|
|
|
def god_developers(self):
|
|
|
|
return self.count_agents(skill_level='God')
|
|
|
|
|
2023-04-09 02:19:24 +00:00
|
|
|
|
|
|
|
sim = Simulation(name='torvalds_example',
|
|
|
|
max_steps=10,
|
|
|
|
interval=2,
|
|
|
|
model=TorvaldsEnv)
|