donjuan.grid

Module Contents

Classes

Grid

Abstract base class for a grid of cells. The underlying grid can either

SquareGrid

Rectangular grid of square cells. In a square grid, the cell positions are

HexGrid

Rectangular grid of hexagonal cells. In a hex grid, the cell positions

class donjuan.grid.Grid(n_rows: int, n_cols: int, cells: Optional[List[List[Cell]]] = None, edges: Optional[List[List[List[Edge]]]] = None)[source]

Bases: abc.ABC

Abstract base class for a grid of cells. The underlying grid can either be square or hexagonal.

get_filled_grid(self) → List[List[bool]][source]

Obtain a 2D array of boolean values representing the filled state of the cells attached to the grid.

property n_rows(self) → int
property n_cols(self) → int
property cells(self) → List[List[Cell]]
property edges(self) → List[List[List[Edge]]]
reset_cell_coordinates(self) → None[source]

Helper function that sets the coordinates of the cells in the grid to their index values.

check_edges(self, edges: Optional[List[List[List[Edge]]]]) → None[source]

Check the dimensions of the edges.

init_edges(self) → List[List[List[Edge]]][source]

For an Edge, the Edge.cell1 always points to either the left or upper Cell. The Edge.cell2 always points to the right or the bottom.

class donjuan.grid.SquareGrid(n_rows: int, n_cols: int, cells: Optional[List[List[SquareCell]]] = None)[source]

Bases: donjuan.grid.Grid

Rectangular grid of square cells. In a square grid, the cell positions are integers.

cell_type
class donjuan.grid.HexGrid(n_rows: int, n_cols: int, cells: Optional[List[List[HexCell]]] = None)[source]

Bases: donjuan.grid.Grid

Rectangular grid of hexagonal cells. In a hex grid, the cell positions are integers, with odd rows being “offset” by half a cell size when rendered.

cell_type