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.ABC
A 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 aname
and knows about any entrances to the room (a list of Edge objects) via theentrances
property.- 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
cells
set and the cell coordinates to thecell_coordinates
set.- 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)
whereN
is the number of cells in this space, since set lookup isO(1)
.- Parameters
other (Space) – other space to check against
- Returns
True
if they overlap,False
if not