In [ ]:
In [5]:
class Grid2D(object):
"""
2-D grid class.
"""
pass
class InformationNetwork(object):
"""
Information diffusion network.
"""
pass
In [41]:
class Model(object):
"""
Model class.
"""
def __init__(self, population_size=100,
initial_zombies=1,
grid_size=20,
information_network_type="default",
infection_rate=0.1,
defend_probability=0.1,
human_speed=1,
zombie_speed=1,
pheromone_deposit_rate=0.1,
pheromone_dissipation_rate=0.1
):
"""
Constructor.
"""
# Top level model parameters
self.population_size = population_size
self.initial_zombies = initial_zombies
self.grid_size = grid_size
self.information_network_type = information_network_type
self.defend_probability = defend_probability
self.human_speed = human_speed
self.zombie_speed = zombie_speed
self.pheromone_deposit_rate = pheromone_deposit_rate
self.pheromone_dissipation_rate = pheromone_dissipation_rate
# Storage
self.agent_list = []
# Call setup methods
self.create_agents()
def create_agents(self):
"""
Create the agents for the model.
"""
# Create humans
for agent_id in range(self.population_size):
self.agent_list.append(Human(self, agent_id,
self.human_speed,
self.defend_probability))
# Create zombies
for zombie_id in range(self.initial_zombies):
# Get agent ID
agent_id = self.population_size + zombie_id
self.agent_list.append(Zombie(self, agent_id,
self.zombie_speed,
self.defend_probability))
In [43]:
for i in range(len(m.agent_list)):
print((i, m.agent_list[i].agent_id))
In [44]:
m = Model(population_size=10, initial_zombies=2)
print(m.agent_list)
Qualitatively, humans can:
Qualitatively, zombies can:
* totally random
* human-pheremone driven
In [18]:
class Human(object):
"""
Human class.
"""
def __init__(self, model, agent_id,
human_speed, defend_probability):
# Set agent parameters
self.model = model
self.agent_id = agent_id
self.human_speed = human_speed
self.defend_probability = defend_probability
class Zombie(object):
"""
Zombie class.
"""
def __init__(self, model, agent_id,
zombie_speed, defend_probability):
# Set agent parameters
self.model = model
self.agent_id = agent_id
self.zombie_speed = zombie_speed
self.defend_probability = defend_probability