def test_flu_game(self): """ Flu game simulates flu expanding through social network. """ # Network construction. agents = {} for _ in range(100): agent = Agent() agent.set_fitness("infected", InfectedFitness()) agents[agent.get_id()] = agent for agent in agents: agents[agent].update_fitness_measure("infected", True) break topology = generate_topology("clique", agents_names=agents.keys()) changes = {1: "clique"} network = Network(agents, {"clique": topology}, changes) # Interaction construction. interactions = BehaviorSwitcher({ "infection": InfectInteraction() }, {1: "infection"}) # Environment construction. environment = BehaviorSwitcher({}, {}) # Results construction. result = StandardResult(1) # Condition construction. condition = AllInfected() # Simulation construction. self.simulation = Simulation(network, interactions, environment, result, condition) simulation_result = self.simulation.run()
def __init__(self, aid=None, lexicon=None): Agent.__init__(self, aid) self.lexicon = lexicon or Lexicon()