def countNeighbours(self, cell):
count = <NUM_LIT:0><EOL>y, x = cell<EOL>y = y % self.y_grid<EOL>x = x % self.x_grid<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>cell = y, x<EOL>for neighbour in product([y1, y, y2], [x1, x, x2]):<EOL><INDENT>if neighbour != cell and self.grid.get(neighbour):<EOL><INDENT>count += <NUM_LIT:1><EOL><DEDENT><DEDENT>return count<EOL>
Return the number active neighbours within one positions away from cell