Exemplo n.º 1
0
def test_cell_status():
    grid = make_grid('test2', size=(5, 5), live_cells=[0, 3, 12, 18, 21])
    status = cell_status(grid)
    assert status((0, 0)) == 1
    assert status((0, 3)) == 1
    assert status((2, 0)) == 0
    assert status((3, 4)) == 0
Exemplo n.º 2
0
def test_neighbors():
    grid = make_grid('test2', size=(5, 5), live_cells=[0, 3, 12, 18, 21])
    get_neighbours = neighbours(grid)
    p1 = id_to_pos(0, grid)
    assert get_neighbours(p1) == [(0, 1), (1, 0), (1, 1)]
    p2 = id_to_pos(18, grid)
    assert get_neighbours(p2) == [(2, 2), (2, 3), (2, 4),
                                  (3, 2),         (3, 4),
                                  (4, 2), (4, 3), (4, 4)]
    p3 = id_to_pos(24, grid)
    assert get_neighbours(p3) == [(3, 3), (3, 4), (4, 3)]
Exemplo n.º 3
0
def test_make_cells():
    g1 = make_grid('test1', size=(2, 2), live_cells=[0, 3])
    assert g1.cells == [1, 0, 0, 1]
    assert g1.rows == 2
    assert g1.cols == 2
    assert g1.name == 'test1'