def __init__(self, methodName, prop_file="models/coop_for_test.props"): super().__init__(methodName=methodName) self.pa = props.read_props(MODEL_NM, prop_file) # Now we create a forest environment for our agents to act within: self.env = cm.CoopEnv(model_nm=MODEL_NM, props=self.pa) for i in range(self.pa["num_agents"]): self.env.add_agent(cm.CoopAgent('agent' + str(i), 5, 0)) self.env.add_agent(cm.CoopAgent('agent for tracking', 5, 0))
def test_add_agent(self): announce('test_add_agent') self.env.add_agent(cm.CoopAgent('new added agent', 5, 0)) # test if the add worked! # test by running new_agent = self.env.agent_inspect("new added agent") self.assertIsNotNone(new_agent)
def run(prop_dict=None): (prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM) global pa env = cm.CoopEnv(model_nm=MODEL_NM, props=pa) for i in range(pa["num_agents"]): env.add_agent(cm.CoopAgent('agent' + str(i), 5, 0)) return utils.run_model(env, prog_file, results_file)