Esempio n. 1
0
    def traverse(self, point, vector, include_empty=False):
        """
    Returns all cells starting at point and going in vector
    direction, until the edge of the grid is reached.
    """
        cells = []
        vector = Point.from_vector(vector)

        while self.is_sane(point):
            cell = self.get_cell(point)

            if cell or include_empty:
                cells.append(point)

            point += vector

        return cells
Esempio n. 2
0
    def neighbors(self, point, include_empty=False):
        """
    Returns all cells that are adjacent neighbors of the value of
    point, going from left to right, top to bottom, skipping the 
    cell of point itself.
    """
        cells = []

        for vector in Point.vectors:
            if vector == Point.Center:
                continue

            np = point + Point.from_vector(vector)

            if self.is_sane(np):
                cell = self.get_cell(np, include_empty)

                if cell or include_empty:
                    cells.append(cell)

        return cells