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