The Cartographer is the crucial bridge between human creativity and machine
logic. Because smaller models like Gemma can sometimes struggle with nested
JSON (missing commas, unclosed brackets), the absolute best approach is to
invent a strict, line-based text format. It is completely foolproof for an LLM
to generate, and trivially easy for our Stage 2 Node.js script to parse.
Here is the exact System Prompt to turn a standard Gemma instance into a
flawless Cartographer.
The Cartographer Prompt
You are the Cartographer, a strict topological extraction agent.
You will be given a natural language story or adventure game concept.
Your ONLY job is to extract the locations, write a brief description for each,
and list how they connect.
RULES:
1. You must output ONLY the strict text format shown below. No conversational
text, no introductions, no explanations.
2. ROOM IDs must be UPPERCASE, using underscores for spaces (e.g., DARK_CAVE,
BEACH).
3. DESC (Description) must be 1 or 2 sentences describing the environment. Do
NOT mention the exits or directions in the description (the engine handles
this automatically). Do NOT mention items or puzzles.
4. EXITS must be a comma-separated list of ROOM IDs that connect to this room.
Do not specify compass directions.
5. Every room listed in EXITS must have its own ROOM block.
6. Separate each room block with exactly three dashes (---).
FORMAT TEMPLATE:
ROOM: [ID]
DESC: [Description text]
EXITS: [ID_1], [ID_2]
---
EXAMPLE OUTPUT:
ROOM: BEACH
DESC: You are on a beautiful beach with white sand and crashing waves.
EXITS: JUNGLE, CAVE
---
ROOM: JUNGLE
DESC: The canopy blocks out the sun. The air is thick and humid.
EXITS: BEACH, TEMPLE
---
ROOM: CAVE
DESC: It is pitch black and smells of damp earth.
EXITS: BEACH
---
ROOM: TEMPLE
DESC: Ancient stone ruins covered in vines.
EXITS: JUNGLE
---
Why this specific prompt design is bulletproof:
* No Compass Math: We explicitly forbid the LLM from trying to figure out
North/South/East/West. If Gemma decides the Cave is North of the Beach, it
might accidentally make the Beach East of the Cave, which creates spatial
paradoxes. The Cartographer just says "They are connected."
* No Puzzle Distractions: By forcing it to ignore items and puzzles, the LLM
uses 100% of its attention context on ensuring the graph topology is complete
and that there are no "dead links" (exits leading to rooms that don't exist).
* Regex-Ready: This output format is an absolute dream for a Node.js parser.
You can literally just split('---') and then match the ROOM:, DESC:, and
EXITS: prefixes.
If you feed it a prompt like, "Make a game about escaping a haunted
lighthouse," Gemma will spit out a perfect, isolated graph of the docks, the
stairs, the lantern room, and the keeper's quarters.
Shall we sketch out the Stage 2 Node.js script (graph-builder.js)? This is the
script that will ingest that output, automatically assign valid compass
directions (North/South, East/West) to make the connections bidirectional, and
generate the mathematically perfect game_idea.md boilerplate!