Structuring the pipeline to capture both a topological MUD graph and a
Euclidean 2D tile map is a highly effective approach. By using page numbers as
a temporal z-axis, you are essentially extracting a 4D database (x, y, room,
time) from linear text.
Here is how you can architect the systems to support both the MUD REPL and the
Rogue-like visual grid, keeping the data cleanly separated.
1. The Semantic Metadata Store (The Concept Graph)
Instead of forcing rooms into coordinates immediately, the initial passes
build an abstract graph. Every location, NPC, and item becomes a node with a
unique identifier (e.g., CH1_LIVING_ROOM).
As the scanner progresses through the text, it updates these nodes
dynamically. Because this is heavily state-dependent and requires frequent
reads/writes during the scanning process, this graph can reside in a lock-free
in-memory data structure.
* Bi-directional Links: The node stores an array of references to the source
text (e.g., mentions: [{page: 12, line: 40}, {page: 45, line: 12}]).
* Property Accumulation: If page 12 mentions "a dusty rug" and page 45
mentions "the living room's broken window," the CH1_LIVING_ROOM metadata
accumulates both features into its state.
2. The Timeline Array (Event Sourcing)
Using page numbers as a proxy for time allows you to extract an event stream.
This acts identically to a Write-Ahead Log (WAL) for your game's narrative
state.
Rather than placing an NPC statically in a room, you record their trajectory:
[ { tick: 12, actor: "Goblin", action: "SPAWN", loc: "CH1_CAVERN" }, { tick:
15, actor: "Goblin", action: "MOVE", loc: "CH1_TUNNEL" } ]
In the MUD engine, this event stream can drive NPC scheduling. When the player
enters a room, the engine calculates the current "story tick" and resolves the
event stream to determine which NPCs are present and what dialogue state they
are in.
3. Resolving the MUD Graph vs. The Rogue Grid
Books are inherently non-Euclidean. An author can write, "He walked out of the
bedroom and into the sprawling forest," skipping the hallway, the front door,
and the street.
The MUD Layer:
This handles the spatial jumps effortlessly. The graph simply adds an edge:
CH1_BEDROOM -> exit: "forest" -> CH2_FOREST. The MUD REPL reads this directly.
The Rogue-like Layer:
To generate a 2D canvas or WebGL grid renderer from this graph, a Version 2
organizer script needs to apply spatial constraints:
* Island Generation: Group rooms that belong to the same chapter or semantic
cluster (e.g., all CH1_ rooms) onto an endless 2D plane.
* Room Carving: Randomly generate the dimensions for these semantic rooms
(e.g., a 5x5 cavern, a 3x4 lobby).
* Pathfinding: Use algorithms like A* or a drunken-walk to dig walkable
tunnel tiles connecting the rooms based on the MUD exit graph.
* Handling "TARDIS" Geometry: When the script encounters a non-Euclidean jump
(the bedroom connecting directly to the forest), it should not try to dig a
500-tile tunnel. Instead, it places a portal, a staircase, or a map-edge
transition zone.
By dumping this final layout into a structured snapshot format (like an AST-MD
file), you create a clean hand-off point. An AI or human map editor can load
this snapshot, visually tweak the generated caverns, fix overlapping walls,
and save it back out for the game engine to mount.