grammex generates dungeon layouts using
graph grammar rewriting. Starting from a seed graph
(an entrance node), the engine repeatedly applies transformation
rules that replace subgraph patterns with more complex structures.
Rules
Each rule has a left-hand side (LHS) pattern to match and
a right-hand side (RHS) replacement. For example, a rule
might replace a single room node with a room connected to a key and
a locked door.
Constraints
After each rule application, structural constraints are verified.
If a constraint is violated, the application is rolled back and a
different match is tried. This guarantees the generated dungeon is
always completable.