예제 #1
0
파일: example.py 프로젝트: yattom/pypattern
 def reset(self, cells=[]):
     for y, l in enumerate(cells):
         for x, c in enumerate(l):
             switch(c,
                    '_', lambda: self.cells[(x, y)].die(),
                    '*', lambda: self.cells[(x, y)].live(),
                    '*', lambda: self.cells.__setitem__((x, y), Cell.ALIVE))
예제 #2
0
 def next(self):
     for cell in self.cells.values():
         count = len(filter(lambda c: c.state == Cell.ALIVE,
                            cell.neighbors))
         cell.next_state = switch(count, 2, cell.state, 3, Cell.ALIVE,
                                  Cell.DEAD)
     for cell in self.cells.values():
         cell.tick()
예제 #3
0
파일: example.py 프로젝트: yattom/pypattern
 def next(self):
     for cell in self.cells.values():
         count = len(filter(lambda c: c.state == Cell.ALIVE, cell.neighbors))
         cell.next_state = switch(
             count,
             2, cell.state,
             3, Cell.ALIVE,
             Cell.DEAD)
     for cell in self.cells.values():
         cell.tick()
예제 #4
0
 def reset(self, cells=[]):
     for y, l in enumerate(cells):
         for x, c in enumerate(l):
             switch(c, '_', lambda: self.cells[
                 (x, y)].die(), '*', lambda: self.cells[(x, y)].live(), '*',
                    lambda: self.cells.__setitem__((x, y), Cell.ALIVE))
예제 #5
0
 def tick(self):
     switch(self.state(),
            'seed', self.tick_for_seed,
            'rooted', self.tick_for_rooted,
            'sprouted', self.tick_for_sprouted)