Example #1
0
def test__cell_die_without_required_number_of_neighbor():
    old_grid = [
        [0, 0, 0, 0],
        [0, 1, 1, 0],
        [0, 0, 0, 0],
    ]
    result = run_next_generation(old_grid)
    cell_with_1_neighbors = result[1][1]
    assert cell_with_1_neighbors == 0
Example #2
0
def test__dead_cell_without_neighbors_become_alive():
    old_grid = [
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
    ]
    result = run_next_generation(old_grid)
    assert result == [
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
    ]
Example #3
0
def test__dead_grid_is_in_next_generation_full_of_life():
    empty_grid = [
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
    ]
    result = run_next_generation(empty_grid)
    assert result == [
        [1, 1, 1, 1],
        [1, 1, 1, 1],
        [1, 1, 1, 1],
    ]
Example #4
0
def test__alive_cell_with_enough_alive_neighbors_survive(grid):
    result = run_next_generation(grid)
    cell_with_enough_neighbors = result[1][1]
    assert cell_with_enough_neighbors == 1
Example #5
0
def test__dead_cell_with_one_neighbor_become_alive():
    old_grid = [[1, 0]]
    result = run_next_generation(old_grid)
    assert result == [[0, 1]]
Example #6
0
 def _generate(self) -> List[List[int]]:
     grid = generate_random_grid()
     new_grid = run_next_generation(grid)
     new_grid = run_next_generation(new_grid)
     new_grid = create_grid_with_reflection(new_grid)
     return add_neuman_border(new_grid)