Example #1
0
def test_apply_rules_rule3_2():
    # Any live cell with more than three live neighbours dies, as if by overpopulation.
    board = [[True, False, True, True], [True, True, True, True],
             [False, True, True, False], [True, True, True, True]]
    assert life.alive(board, 0, 2)
    board = life.apply_rules(board)
    assert not life.alive(board, 0, 2)
Example #2
0
def test_alive_alive():
    board = [[False, False, False], [False, False, True],
             [False, False, False]]
    val = life.alive(board, 1, 2)
    assert val == True
Example #3
0
def test_alive_dead():
    board = [[True, True, True], [True, True, False], [True, True, True]]
    val = life.alive(board, 1, 2)
    assert val == False
Example #4
0
def test_apply_rules_rule4():
    # Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
    board = [[True, False, True], [False, True, False], [False, False, False]]
    assert not life.alive(board, 0, 1)
    board = life.apply_rules(board)
    assert life.alive(board, 0, 1)
Example #5
0
def test_apply_rules_rule2_3_live_neighbours():
    # Any live cell with two or three live neighbours lives on to the next generation.
    board = [[True, True, True], [False, True, False], [False, False, False]]
    assert life.alive(board, 0, 1)
    board = life.apply_rules(board)
    assert life.alive(board, 0, 1)
Example #6
0
def test_apply_rules_rule1():
    # Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
    board = [[True, True, True], [False, False, False], [False, False, False]]
    assert life.alive(board, 0, 0)
    board = life.apply_rules(board)
    assert not life.alive(board, 0, 0)