Beispiel #1
0
    def test_update_cells_line(self):

        colony = Cells(50)
        colony.choose_cells([[0, 1, 0], [0, 1, 0], [0, 1, 0]])
        expected = np.array([[0, 0, 0], [1, 1, 1], [0, 0, 0]])
        colony.live_or_die()
        actual = colony.get_array()
        self.assertTrue((expected == actual).all())

        colony.live_or_die()
        expected = np.array([[0, 1, 0], [0, 1, 0], [0, 1, 0]])
        actual = colony.get_array()
        self.assertTrue((expected == actual).all())
Beispiel #2
0
    def test_update_cells_basic(self):

        colony = Cells(50)
        colony.kill_cells()
        expected = np.zeros((50, 50))
        colony.live_or_die()
        actual = colony.get_array()
        self.assertTrue((expected == actual).all())

        colony.choose_cells([[1, 1], [0, 0]])
        colony.live_or_die()
        actual = colony.get_array()
        expected = np.array([[0, 0], [0, 0]])
        self.assertTrue((expected == actual).all())

        colony.choose_cells([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
        colony.live_or_die()
        actual = colony.get_array()
        expected = np.array([[1, 0, 1], [0, 0, 0], [1, 0, 1]])
        self.assertTrue((expected == actual).all())