Exemplo n.º 1
0
    def test_get_neighbours(self):

        clist = CellList.from_file('grid.txt')

        neighbours = clist.get_neighbours(Cell(2, 3))

        self.assertEquals(8, len(neighbours))

        self.assertEquals(4, sum(c.is_alive() for c in neighbours))
Exemplo n.º 2
0
    def test_get_neighbours_for_right_side(self):

        clist = CellList.from_file('grid.txt')

        neighbours = clist.get_neighbours(Cell(2, 7))

        self.assertEquals(5, len(neighbours))

        self.assertEquals(2, sum(c.is_alive() for c in neighbours))
Exemplo n.º 3
0
    def test_get_neighbours_for_lower_right_corner(self):

        clist = CellList.from_file('grid.txt')

        neighbours = clist.get_neighbours(Cell(5, 7))

        self.assertEquals(3, len(neighbours))

        self.assertEquals(1, sum(c.is_alive() for c in neighbours))
 def test_can_create_a_cell(self):
     cell = Cell(0, 0)
     self.assertFalse(cell.is_alive())
 def test_can_create_a_cell(self):
     cell = Cell(0, 0, state=True)
     self.assertTrue(cell.is_alive())
Exemplo n.º 6
0
 def test_get_neighbours_for_upper_side(self):
     clist = CellList.from_file('grid.txt')
     neighbours = clist.get_neighbours(Cell(0,3))
     self.assertEqual(5, len(neighbours))
     self.assertEqual(4, sum(c.is_alive() for c in neighbours))
Exemplo n.º 7
0
 def test_get_neighbours_for_upper_left_corner(self):
     clist = CellList.from_file('grid.txt')
     neighbours = clist.get_neighbours(Cell(0,0))
     self.assertEqual(3, len(neighbours))
     self.assertEqual(2, sum(c.is_alive() for c in neighbours))