Ejemplo n.º 1
0
    def test_live_cell_with_more_than_three_live_neighbors_dies(self):
        world = World((50, 50))

        Cell(4, 6, world, initially_alive=True)
        Cell(4, 5, world, initially_alive=True)
        Cell(4, 4, world, initially_alive=True)
        Cell(5, 6, world, initially_alive=True)
        Cell(5, 4, world)
        Cell(6, 6, world)
        Cell(6, 5, world)
        Cell(6, 4, world)

        test_cell = Cell(5, 5, world, True)

        self.assertFalse(test_cell.next())
Ejemplo n.º 2
0
    def test_live_cell_with_two_live_neighbors_lives(self):
        world = World((50, 50))

        Cell(4, 6, world, initially_alive=True)
        Cell(4, 5, world, initially_alive=True)
        Cell(4, 4, world)
        Cell(5, 6, world)
        Cell(5, 4, world)
        Cell(6, 6, world)
        Cell(6, 5, world)
        Cell(6, 4, world)

        test_cell = Cell(5, 5, world, True)

        self.assertTrue(test_cell.next())
Ejemplo n.º 3
0
    def test_dead_cell_with_exactly_three_live_neighbors_becomes_alive(self):
        world = World((50, 50))

        Cell(4, 6, world, initially_alive=True)
        Cell(4, 5, world, initially_alive=True)
        Cell(4, 4, world, initially_alive=True)
        Cell(5, 6, world)
        Cell(5, 4, world)
        Cell(6, 6, world)
        Cell(6, 5, world)
        Cell(6, 4, world)

        test_cell = Cell(5, 5, world)

        self.assertTrue(test_cell.next())
Ejemplo n.º 4
0
    def test_can_progress_cell_to_next_generation(self):
        world = World((50, 50))

        Cell(4, 6, world, initially_alive=True)
        Cell(4, 5, world, initially_alive=True)
        Cell(4, 4, world, initially_alive=True)
        Cell(5, 6, world)
        Cell(5, 4, world)
        Cell(6, 6, world)
        Cell(6, 5, world)
        Cell(6, 4, world)

        test_cell = Cell(5, 5, world)

        self.assertTrue(test_cell.next())
        self.assertFalse(test_cell.is_alive)

        test_cell.step()

        self.assertIsNone(test_cell._next)
        self.assertTrue(test_cell.is_alive)