Example #1
0
File: grid.py Project: Vultaire/gol
 def iterate(self):
     new_grid = Grid()
     for x, y in self.get_candidate_cells():
         neighbors = self.get_num_of_neighbors(x, y)
         alive_now = self[(x, y)]
         alive_next = alive_next_turn(neighbors, alive_now)
         if alive_next:
             new_grid[(x, y)] = True
     return new_grid
Example #2
0
File: grid.py Project: Vultaire/gol
 def iterate(self):
     new_grid = Grid()
     for x, y in self.get_candidate_cells():
         neighbors = self.get_num_of_neighbors(x, y)
         alive_now = self[(x, y)]
         alive_next = alive_next_turn(neighbors, alive_now)
         if alive_next:
             new_grid[(x, y)] = True
     return new_grid
Example #3
0
def test_statusquo_2_neighbors_and_alive_stays_alive():
    assert alive_next_turn(2, True)
Example #4
0
def test_underpop():
    assert not alive_next_turn(1, True)
Example #5
0
def test_overpop():
    assert not alive_next_turn(4, True)
Example #6
0
def test_birth():
    assert alive_next_turn(3, False)
Example #7
0
def test_statusquo_2_neighbors_and_dead_stays_dead():
    assert not alive_next_turn(2, False)
Example #8
0
def test_statusquo_3_neighbors_and_alive_stays_alive():
    assert alive_next_turn(3, True)
Example #9
0
def test_statusquo_2_neighbors_and_dead_stays_dead():
    assert not alive_next_turn(2, False)
Example #10
0
def test_underpop():
    assert not alive_next_turn(1, True)
Example #11
0
def test_overpop():
    assert not alive_next_turn(4, True)
Example #12
0
def test_birth():
    assert alive_next_turn(3, False)