Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
def test_statusquo_2_neighbors_and_alive_stays_alive():
    assert alive_next_turn(2, True)
Exemple #4
0
def test_underpop():
    assert not alive_next_turn(1, True)
Exemple #5
0
def test_overpop():
    assert not alive_next_turn(4, True)
Exemple #6
0
def test_birth():
    assert alive_next_turn(3, False)
Exemple #7
0
def test_statusquo_2_neighbors_and_dead_stays_dead():
    assert not alive_next_turn(2, False)
Exemple #8
0
def test_statusquo_3_neighbors_and_alive_stays_alive():
    assert alive_next_turn(3, True)
Exemple #9
0
def test_statusquo_2_neighbors_and_dead_stays_dead():
    assert not alive_next_turn(2, False)
Exemple #10
0
def test_underpop():
    assert not alive_next_turn(1, True)
Exemple #11
0
def test_overpop():
    assert not alive_next_turn(4, True)
Exemple #12
0
def test_birth():
    assert alive_next_turn(3, False)