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