The SimpleNeighbourhood offers named access to any number of neighbouring fields with any number of dimensions.
The names of neighbourhood fields.
The offsets of neighbourhood fields.
Adds C and python code to get the neighbouring values and stores them in local variables.
Calculate a bounding box from a set of offsets.
Get the bounding box resulting from step successive reads.
The return value will have an outer tuple with one tuple for each dimension. Each dimension will have a min and a max value.
>>> a = SimpleNeighbourhood(list("lmr"), ((-1,), (0,), (1,))) >>> a.bounding_box() ((-1, 1),) >>> a.bounding_box(2) ((-2, 2),) >>> b = SimpleNeighbourhood(list("ab"), ((-5, 20), (99, 10))) >>> b.bounding_box() ((-5, 99), (10, 20)) >>> b.bounding_box(10) ((-50, 990), (100, 200))
Get all positions of cells that have the cell at (0, 0) in their neighbourhood.
This is the neighbourhood used by the elementary cellular automatons.
The neighbours are called l, m and r for left, middle and right.
This is the Von Neumann Neighbourhood, in which the cell itself and the left, upper, lower and right neighbours are considered.
The neighbours are called l, u, m, d and r for left, up, middle, down and right respectively.
This is the Moore Neighbourhood. The cell and all of its 8 neighbours are considered for computation.
The fields are called lu, u, ru, l, m, r, ld, d and rd for left-up, up, right-up, left, middle, right, left-down, down and right-down respectively.