Esempio n. 1
0
    def test_five_live_neighbours(self):
        game = Game()
        cell = Cell(Initial_status=True)
        cell_to_right = Cell(Initial_status=True)
        cell_to_bottom_right = Cell(Initial_status=True)
        cell_to_bottom = Cell(Initial_status=True)
        cell_to_bottom_left = Cell(Initial_status=True)
        cell_to_left = Cell(Initial_status=True)
        cell_to_top_left = Cell(Initial_status=True)
        cell_to_top = Cell(Initial_status=False)
        cell_to_top_right = Cell(Initial_status=False)

        observed_square = [cell_to_right, cell_to_bottom_right,
                           cell_to_bottom, cell_to_bottom_left, cell_to_left,
                           cell_to_top_left, cell_to_top, cell_to_top_right]

        game.run(cell, observed_square)
        assert (cell.status == False)
Esempio n. 2
0
    def test_get_count_of_alive_neighbours(self):
        # cell = Cell(Initial_status=True)
        cell_to_right = Cell(Initial_status=False)
        cell_to_bottom_right = Cell(Initial_status=False)
        cell_to_bottom = Cell(Initial_status=True)
        cell_to_bottom_left = Cell(Initial_status=False)
        cell_to_left = Cell(Initial_status=True)
        cell_to_top_left = Cell(Initial_status=False)
        cell_to_top = Cell(Initial_status=False)
        cell_to_top_right = Cell(Initial_status=False)

        observed_square = [cell_to_right, cell_to_bottom_right,
                           cell_to_bottom, cell_to_bottom_left, cell_to_left,
                           cell_to_top_left, cell_to_top, cell_to_top_right]

        game = Game()
        count_of_alive_neighbours = game.get_count_of_alive_neighbours(observed_square)

        assert (count_of_alive_neighbours == 2)