def test_model_with_agent_and_helper(self): # Testing with a helper that changes the state of an agent model = Model(5) agent = SimpleAgent() helper = SimpleHelper() model.schedule.agents.add(agent) model.schedule.helpers.append(helper) model.run() self.assertEqual(model.schedule.agents.pop().a, 62)
def test_simple_model(self): model = Model(5) agent = SimpleAgent() model.schedule.agents.add(agent) model.run() self.assertEqual(model.schedule.agents.pop().a, 5)
return if current_position[0] == xlimit: new_position = (0, current_position[1] + 1) else: new_position = (current_position[0] + 1, current_position[1]) self.move_agent("agent_env", new_position, model) xsize = ysize = 20 model = Model(xsize * ysize + 5) # Creating the grid automatically binds it to the model ObjectGrid2D("agent_env", xsize, ysize, model) numerical_env = NumericalGrid2D("value_env", xsize, ysize, model) # Adding the agent to the schedule and to the environment agent = SimpleAgent() model.schedule.agents.add(agent) agent.add_agent_to_grid("agent_env", (0, 0), model) val = 0 for y in range(ysize): for x in range(xsize): numerical_env.grid[(x, y)] = val val += 1 model.run()
def test_get_epochs(self): model = Model(5) self.assertEqual(0, model.current_epoch) model.run() self.assertEqual(4, model.current_epoch)