def nextGen(self):
self.current_gen += <NUM_LIT:1><EOL>self.change_gen[self.current_gen % <NUM_LIT:3>] = copy.copy(self.grid)<EOL>grid_cp = copy.copy(self.grid)<EOL>for cell in self.grid:<EOL><INDENT>y, x = cell<EOL>y1 = (y - <NUM_LIT:1>) % self.y_grid<EOL>y2 = (y + <NUM_LIT:1>) % self.y_grid<EOL>x1 = (x - <NUM_LIT:1>) % self.x_grid<EOL>x2 = (x + <NUM_LIT:1>) % self.x_grid<EOL>n = self.countNeighbours(cell)<EOL>if n < <NUM_LIT:2> or n > <NUM_LIT:3>:<EOL><INDENT>del grid_cp[cell]<EOL>self.addchar(y + self.y_pad, x + self.x_pad, '<STR_LIT:U+0020>')<EOL><DEDENT>else:<EOL><INDENT>grid_cp[cell] = min(self.grid[cell] + <NUM_LIT:1>, self.color_max)<EOL><DEDENT>for neighbour in product([y1, y, y2], [x1, x, x2]):<EOL><INDENT>if not self.grid.get(neighbour):<EOL><INDENT>if self.countNeighbours(neighbour) == <NUM_LIT:3>:<EOL><INDENT>y, x = neighbour<EOL>y = y % self.y_grid<EOL>x = x % self.x_grid<EOL>neighbour = y, x<EOL>grid_cp[neighbour] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>self.grid = grid_cp<EOL>
Decide the fate of the cells