Example #1
0
 def setUp(self):
     self.space = SingleGrid(50, 50, False)
     self.agents = []
     for i, pos in enumerate(TEST_AGENTS_GRID):
         a = MockAgent(i, None)
         self.agents.append(a)
         self.space.place_agent(a, pos)
Example #2
0
 def test_empty_cells(self):
     if self.space.exists_empty_cells():
         pytest.deprecated_call(self.space.find_empty)
         for i, pos in enumerate(list(self.space.empties)):
             a = MockAgent(-i, pos)
             self.space.position_agent(a, x=pos[0], y=pos[1])
     assert self.space.find_empty() is None
     with self.assertRaises(Exception):
         self.space.move_to_empty(a)
Example #3
0
 def setUp(self):
     """
     Create a test space and populate with Mock Agents.
     """
     self.space = ContinuousSpace(70, 20, True, -30, -30)
     self.agents = []
     for i, pos in enumerate(TEST_AGENTS):
         a = MockAgent(i, None)
         self.agents.append(a)
         self.space.place_agent(a, pos)
Example #4
0
 def setUp(self):
     """
     Create a test network grid and populate with Mock Agents.
     """
     G = nx.complete_graph(TestMultipleNetworkGrid.GRAPH_SIZE)
     self.space = NetworkGrid(G)
     self.agents = []
     for i, pos in enumerate(TEST_AGENTS_NETWORK_MULTIPLE):
         a = MockAgent(i, None)
         self.agents.append(a)
         self.space.place_agent(a, pos)
Example #5
0
    def test_bounds(self):
        """
        Test positions outside of boundary
        """
        for i, pos in enumerate(OUTSIDE_POSITIONS):
            a = MockAgent(len(self.agents) + i, None)
            with self.assertRaises(Exception):
                self.space.place_agent(a, pos)

        a = self.agents[0]
        for pos in OUTSIDE_POSITIONS:
            assert self.space.out_of_bounds(pos)
            with self.assertRaises(Exception):
                self.space.move_agent(a, pos)
Example #6
0
    def test_bounds(self):
        """
        Test positions outside of boundary
        """
        boundary_agents = []
        for i, pos in enumerate(OUTSIDE_POSITIONS):
            a = MockAgent(len(self.agents) + i, None)
            boundary_agents.append(a)
            self.space.place_agent(a, pos)

        for a, pos in zip(boundary_agents, OUTSIDE_POSITIONS):
            adj_pos = self.space.torus_adj(pos)
            assert a.pos == adj_pos

        a = self.agents[0]
        for pos in OUTSIDE_POSITIONS:
            assert self.space.out_of_bounds(pos)
            self.space.move_agent(a, pos)