Exemple #1
0
    def test_set_cell_status_to_dead(self):
        game = GameOfLife(10, 10)

        game.set_cell(5, 4, False)
        game.set_cell(1, 2, True)

        assert_false(game.is_cell_alive(x=5, y=4))
        assert_true(game.is_cell_alive(x=1, y=2))
Exemple #2
0
    def test_well_populated_area_cell_dies(self):
        game = GameOfLife(10, 10)
        game.set_cell(5, 5)
        game.set_cell(4, 5)
        game.set_cell(5, 4)
        game.set_cell(4, 4)

        game.step()

        assert_true(game.is_cell_alive(x=5, y=4))
        assert_true(game.is_cell_alive(x=4, y=4))
        assert_true(game.is_cell_alive(x=5, y=5))
        assert_true(game.is_cell_alive(x=4, y=5))
Exemple #3
0
    def test_detached_cell_dies(self):
        game = GameOfLife(10, 10)
        game.set_cell(5, 5)

        game.step()

        assert_false(game.is_cell_alive(x=5, y=5))
Exemple #4
0
    def test_set_cell_status(self):
        game = GameOfLife(10, 10)

        game.set_cell(5, 4)
        game.set_cell(1, 2)

        assert_true(game.is_cell_alive(x=5, y=4))
        assert_true(game.is_cell_alive(x=1, y=2))
Exemple #5
0
    def test_underpopulated_area_cell_dies(self):
        game = GameOfLife(10, 10)
        game.set_cell(5, 5)
        game.set_cell(5, 6)

        game.step()

        assert_false(game.is_cell_alive(x=5, y=5))
        assert_false(game.is_cell_alive(x=5, y=6))
Exemple #6
0
    def test_overpopulated_area_cell_dies(self):
        game = GameOfLife(10, 10)
        game.set_cell(0, 0)
        game.set_cell(1, 1)
        game.set_cell(0, 1)
        game.set_cell(1, 0)
        game.set_cell(2, 1)

        game.step()

        assert_false(game.is_cell_alive(x=1, y=1))
Exemple #7
0
    def test_is_cell_alive_or_dead(self):
        game = GameOfLife(5, 5)
        game.set_cell(1, 1)

        assert_true(game.is_cell_alive(x=1, y=1))
        assert_false(game.is_cell_alive(x=2, y=1))