donjuan.space¶
Module Contents¶
Classes¶
A space is a section of a dungeon composed of `Cell`s. This object |
-
class
donjuan.space.Space(cells: Optional[Set[Cell]] = None, name: Union[int, str] = '')[source]¶ Bases:
abc.ABCA space is a section of a dungeon composed of Cell`s. This object contains these cells in a ``set` under the property
cells. It also has anameand knows about any entrances to the room (a list of Edge objects) via theentrancesproperty.- Parameters
cells (Optional[Set[Cell]]) – cells that make up this space
name (Union[int, str], optional) – defaults to ‘’, the room name
-
property
cells(self) → Set[Cell]¶
-
property
cell_coordinates(self) → Set[Tuple[int, int]]¶
-
property
name(self) → Union[int, str]¶
-
add_cells(self, cells: Sequence[Cell]) → None[source]¶ Add cells to the set of cells in this space. Cells are added to both the
cellsset and the cell coordinates to thecell_coordinatesset.- Parameters
cells (Sequence[Cell]) – any iterable collection of cells
-
overlaps(self, other: Space) → bool[source]¶ Compare the cells of this space to the other space to determine whether they overlap or not. Note, this algorithm is
O(N)whereNis the number of cells in this space, since set lookup isO(1).- Parameters
other (Space) – other space to check against
- Returns
Trueif they overlap,Falseif not