clubsandwich.generators
¶
Level generator utilities.
-
class
clubsandwich.generators.
BSPNode
(rect, is_horz=True, value=None, level=0)¶ Node in a binary space partitioning tree
-
rect
¶ Rect
represented by this node
-
is_horz
¶ True
iff this node is divided down its Y axis;False
otherwise
-
value
¶ Int representing split point between the two children of this node. So if this is a horizontal node and the width is 10, the value could be 6, with the left node taking up 6 cells and the right taking up 4.
-
level
¶ How many levels of parents does this node have?
-
data
¶ Dict of arbitrary data for your game’s use.
-
ancestors
¶ Iterator of
self
and all parents, starting with first parent
-
get_node_at_path
(spec=”)¶ Given a string containing only the characters
'a'
and'b'
, return the node matching the given branches. For example, in a tree with 4 leaves,root.get_node_at_path('aa')
would return the left/top-most leaf.
-
leaves
¶ Iterator of all leaves, left/top-to-right/bottom
-
leftmost_leaf
¶ The left/top-most leaf in the tree
-
max_value
¶ Max value of
BSPNode.value
-
random_leaf
()¶ Returns a random leaf
-
rect_a
¶ Assuming
BSPNode.value
has already been set, return theRect
of child A
-
rect_b
¶ Assuming
BSPNode.value
has already been set, return theRect
of child B
-
rightmost_leaf
¶ The right/bottom-most leaf in the tree
-
sibling_pairs
¶ Iterator of all pairs of siblings
-
-
class
clubsandwich.generators.
RandomBSPTree
(size, min_leaf_size, randrange_func=<function <lambda>>)¶ A randomly generated BSP tree. Pass a dungeon size and minimum leaf size. After initialization, the root’s leaves represent non-overlapping rectangles that completely fill the space.