Compare commits

...
Author SHA1 Message Date
Madison Grubb ff3af2621c update dependencies and improve generator 2026-07-10 19:28:53 -04:00
4 changed files with 1207 additions and 2498 deletions
+1053 -2375
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -15,15 +15,15 @@
"license": "SEE LICENSE IN README.md",
"description": "",
"dependencies": {
"dotenv": "^17.2.1",
"puppeteer": "^24.17.1",
"sharp": "^0.34.3"
"dotenv": "^17.4.2",
"puppeteer": "^25.3.0",
"sharp": "^0.35.3"
},
"devDependencies": {
"@eslint/js": "^10.0.0",
"@eslint/js": "^10.0.1",
"@vitest/coverage-v8": "^4.0.18",
"eslint": "^10.0.0",
"globals": "^17.0.0",
"eslint": "^10.7.0",
"globals": "^17.7.0",
"vitest": "^4.0.18"
}
}
+147 -116
View File
@@ -117,132 +117,163 @@ Output ONLY the two numbered items, one per line. Use colons (:) to separate roo
console.log("Climax Room:", climaxRoom);
// Step 5: Main Content (Locations, Encounters, NPCs, Treasures, Random Events)
const mainContentRaw = await callOllama(
`Based on the following dungeon elements and the need for narrative flow:
Title: "${title}"
// To avoid overloading the AI server with a single huge prompt, we generate
// each section in smaller, focused calls and then stitch them together.
const sharedContext = `Title: "${title}"
Description: "${flavor}"
Core Concepts:
${coreConcepts}
Entrance Room: ${JSON.stringify(entranceRoom)}
Climax Room: ${JSON.stringify(climaxRoom)}
Climax Room: ${JSON.stringify(climaxRoom)}`;
Generate the rest of the dungeon's content to fill the space between the entrance and the climax. CRITICAL: All content must fit on a single one-page dungeon layout with three columns. Keep descriptions rich and evocative with tactical/environmental details.
const locationsRaw = await callOllama(
`${sharedContext}
- **Strictly 3 Locations (EXACTLY 3, no more, no less):** Each with a name (max 6 words) and a description (25-35 words). Each room MUST include:
- Rich environmental features that affect gameplay (lighting, sounds, smells, textures, temperature, visibility)
- Interactable elements that players can use (levers, objects, portals, mechanisms, environmental hazards)
- Multiple approaches or solutions to challenges in the room
- Tactical considerations (cover, elevation, movement restrictions, line of sight)
- Hidden aspects discoverable through interaction or investigation
Format as "Name: description" using colons, NOT em-dashes.
Generate EXACTLY 3 intermediate dungeon locations between the entrance and climax.
EXAMPLE LOCATION:
"Whispering Gallery: Dim phosphorescent fungi line the walls, casting an eerie green glow. The air hums with a low-frequency vibration that makes conversation difficult. Two collapsed pillars create natural cover, while a narrow ledge 10 feet up offers a sniper position. A hidden pressure plate near the entrance triggers a portcullis trap."
Requirements:
- Each location gets a unique name (max 6 words) and a description (25-35 words).
- Include sensory details and environmental features that affect gameplay (lighting, sounds, smells, textures, temperature, visibility).
- Include interactable elements (levers, objects, portals, mechanisms, environmental hazards).
- Include tactical considerations (cover, elevation, movement restrictions, line of sight) and at least one hidden aspect per room.
- **Strictly 6 Encounters:** Numbered 1-6 (for d6 rolling). Name (max 6 words) and details (2 sentences MAX, approximately 25-40 words). Each encounter MUST:
- Start with the room/location name followed by a colon, then the details (e.g., "Location Name: Details text")
- The location name must match one of the actual room names from this dungeon
- Include environmental hazards/opportunities (cover, elevation, traps, interactable objects, terrain features)
- Include tactical considerations (positioning, line of sight, escape routes, bottlenecks, high ground)
- Offer multiple resolution options (combat, negotiation, stealth, puzzle-solving, environmental manipulation, timing-based solutions)
- Include consequences and outcomes tied to player choices
- Integrate with the environmental dynamic element from core concepts
- At least two encounters must be directly tied to the primary faction
Format as "Name: Location Name: details" using colons, NOT em-dashes. CRITICAL: Always start encounter details with the location name and a colon.
Format:
1. Room Name: Description text.
2. Room Name: Description text.
3. Room Name: Description text.
EXAMPLE ENCOUNTER:
"Guardian Golem: Chamber of Echoes: The golem activates when the lever is pulled, blocking the exit. It's vulnerable to water damage from the dripping stalactites. Players can use the pillars for cover or try to disable it by breaking the rune on its back. If defeated peacefully, it reveals a hidden passage."
- **Strictly 4-5 NPCs:** Proper name (max 4 words) and a description (50-65 words). Each NPC MUST include:
- Clear motivation or goal
- Relationship to primary faction
- How they can help or hinder the party
- Quirks or memorable traits
- Multiple interaction possibilities (negotiation, intimidation, help, betrayal)
- One NPC should be a key figure tied to the central conflict
- One should be a member of the primary faction, one should be a potential ally, one should be a rival
Format as "Name: description" using colons, NOT em-dashes.
EXAMPLE NPC:
"Kaelen the Warden: A former guard who was left behind when the faction retreated. He knows the secret passages but demands the party help him escape. He's paranoid and checks over his shoulder constantly. Can be bribed with food or convinced through shared stories of betrayal. Will turn on the party if he thinks they're working with the faction."
- **Strictly 4-5 Treasures:** Name (max 5 words) and a description (30-40 words). Each treasure MUST:
- Include a clear danger or side-effect
- Be connected to a specific encounter, NPC, or room
- Have story significance beyond just value
- Have potential for creative use beyond obvious purpose
- Some should be cursed, have activation requirements, or serve dual purposes
Format as "Name — Description" using em-dash.
EXAMPLE TREASURE:
"Whispering Blade — This dagger amplifies the wielder's voice to a deafening roar when drawn. Found in the Guardian Golem's chamber, it was used to command the construct. The blade is cursed: each use permanently reduces the wielder's hearing. Can be used to shatter glass or stun enemies, but the curse cannot be removed."
- **Strictly 1 Random Events Table:** A d6 table (EXACTLY 6 entries, no more, no less) with random events/wandering encounters. Each entry MUST:
- Have a short, evocative event name (max 4 words)
- Provide interesting complications or opportunities (not just combat)
- Tie to the core concepts and dynamic element
- Add replayability and surprise
- Description should be 15-20 words maximum
- Be UNIQUE and DIFFERENT from each other (no duplicates or generic placeholders)
- Be SPECIFIC to this dungeon's theme, conflict, and dynamic element
Format as numbered 1-6 list under "Random Events:" label. Each event must be formatted as "Event Name: Description text" using colons, NOT em-dashes.
CRITICAL: Each item must be on its own numbered line. DO NOT combine multiple items into a single numbered entry.
EXACT FORMAT REQUIRED (DO NOT use placeholder names like "Location Name", "NPC Name", or "Treasure Name" - use actual creative names):
Locations:
1. Actual Room Name: Description text.
2. Actual Room Name: Description text.
3. Actual Room Name: Description text.
Encounters:
1. Actual Encounter Name: Actual Room Name: Details text.
2. Actual Encounter Name: Actual Room Name: Details text.
3. Actual Encounter Name: Actual Room Name: Details text.
4. Actual Encounter Name: Actual Room Name: Details text.
5. Actual Encounter Name: Actual Room Name: Details text.
6. Actual Encounter Name: Actual Room Name: Details text.
NPCs:
1. Actual Character Name: Description text.
2. Actual Character Name: Description text.
3. Actual Character Name: Description text.
4. Actual Character Name: Description text.
Treasures:
1. Actual Item Name — Description text.
2. Actual Item Name — Description text.
3. Actual Item Name — Description text.
4. Actual Item Name — Description text.
Random Events:
1. Event Name: Event description.
2. Event Name: Event description.
3. Event Name: Event description.
4. Event Name: Event description.
5. Event Name: Event description.
6. Event Name: Event description.
CRITICAL: Every name must be unique and creative. Never use generic placeholders like "Location Name", "NPC Name", "Encounter Name", or "Treasure Name". Use actual descriptive names that fit the dungeon's theme.
CRITICAL: Ensure all spelling is correct. Double-check all words, especially proper nouns, character names, and location names. Verify consistency of names across all sections.
CRITICAL: Location name matching - When writing encounters, the location name in the encounter details MUST exactly match one of the room names you've created (Entrance Room, Climax Room, or one of the 3 Locations). Double-check that every encounter location matches an actual room name.
CRITICAL: Avoid vague language - Do not use words like "some", "various", "several", "many", "few", "things", "stuff", "items", or "objects" without specific details. Be concrete and specific in all descriptions.
CRITICAL: All names required - Every room, encounter, NPC, and treasure MUST have a name. Do not leave names blank or use placeholders. If you cannot think of a name, create one based on the dungeon's theme.
CRITICAL: You MUST output exactly five separate sections with these exact labels on their own lines:
"Locations:"
"Encounters:"
"NPCs:"
"Treasures:"
"Random Events:"
Each section must start with its label on its own line, followed by numbered items. Do NOT combine sections. Do NOT embed encounters in location descriptions. Each item must be on its own numbered line. Do not use any bolding, preambles, or extra text. Do not use em-dashes (—) in encounters or NPCs, only use colons for those sections. Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined, 5, "Step 5: Main Content"
Plain text only. Do not use em-dashes (—). Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined,
5,
"Step 5a: Locations"
);
const encountersRaw = await callOllama(
`${sharedContext}
Existing rooms:
- Entrance: ${entranceRoom?.name}
- Climax: ${climaxRoom?.name}
You will add 3 more locations (from the locations list) and must reference only real room names.
Generate EXACTLY 6 encounters, numbered 1-6 for a d6 table.
Requirements:
- Name (max 6 words) and details (2 sentences MAX, ~25-40 words).
- Each encounter MUST start with the room/location name followed by a colon, then the details (e.g., "Room Name: details").
- The location name must match either the entrance room, climax room, or one of the 3 new locations.
- Include environmental hazards/opportunities and tactical considerations (cover, elevation, traps, bottlenecks, escape routes, high ground).
- Offer multiple resolution options (combat, negotiation, stealth, puzzle-solving, environmental manipulation, timing, etc.).
- At least two encounters must be directly tied to the primary faction from the core concepts.
Format:
1. Encounter Name: Room Name: Details text.
2. Encounter Name: Room Name: Details text.
3. Encounter Name: Room Name: Details text.
4. Encounter Name: Room Name: Details text.
5. Encounter Name: Room Name: Details text.
6. Encounter Name: Room Name: Details text.
Plain text only. Use colons, NOT em-dashes. Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined,
5,
"Step 5b: Encounters"
);
const npcsRaw = await callOllama(
`${sharedContext}
Generate 4-5 important NPCs tied to this dungeon.
Requirements:
- Proper name (max 4 words) and a description (50-65 words).
- Each NPC must have: clear motivation, relationship to the primary faction, how they can help or hinder the adventurers, and memorable quirks/traits.
- Include multiple interaction possibilities (negotiation, intimidation, help, betrayal).
- At least one NPC is a key figure tied to the central conflict.
- At least one NPC is a member of the primary faction, one is a potential ally, and one is a rival.
Format:
1. NPC Name: Description text.
2. NPC Name: Description text.
3. NPC Name: Description text.
4. NPC Name: Description text.
5. NPC Name: Description text. (omit the 5th if only 4 NPCs)
Plain text only. Use colons, NOT em-dashes. Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined,
5,
"Step 5c: NPCs"
);
const treasuresRaw = await callOllama(
`${sharedContext}
Generate 4-5 unique treasures for this dungeon.
Requirements:
- Each treasure has a name (max 5 words) and a description (30-40 words).
- Each treasure includes a clear danger or side-effect.
- Each treasure is connected to a specific encounter, NPC, or room.
- Each has story significance beyond raw value and potential for creative non-obvious uses.
- Some should be cursed, have activation requirements, or serve dual purposes.
Format:
1. Item Name — Description text.
2. Item Name — Description text.
3. Item Name — Description text.
4. Item Name — Description text.
5. Item Name — Description text. (omit the 5th if only 4 treasures)
Plain text only. Use an em-dash (—) between name and description. Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined,
5,
"Step 5d: Treasures"
);
const randomEventsRaw = await callOllama(
`${sharedContext}
Generate a d6 Random Events table for this dungeon (EXACTLY 6 entries).
Requirements:
- Short, evocative event name (max 4 words) plus description (15-20 words).
- Provide interesting complications or opportunities (not just combat).
- Tie directly to the core concepts and the dynamic environmental element.
- Each event must be UNIQUE and clearly different from the others.
Format:
Random Events:
1. Event Name: Description text.
2. Event Name: Description text.
3. Event Name: Description text.
4. Event Name: Description text.
5. Event Name: Description text.
6. Event Name: Description text.
Plain text only. Use colons, NOT em-dashes. Absolutely do not use the word "Obsidian" or "obsidian" anywhere in the output.`,
undefined,
5,
"Step 5e: Random Events"
);
const mainContentRaw = [
"Locations:",
locationsRaw.trim(),
"",
"Encounters:",
encountersRaw.trim(),
"",
"NPCs:",
npcsRaw.trim(),
"",
"Treasures:",
treasuresRaw.trim(),
"",
"Random Events:",
randomEventsRaw.replace(/Random Events:\s*/i, "").trim(),
].join("\n");
const { intermediateRoomsSection, encountersSection, npcsSection, treasureSection, randomEventsSection } =
parseMainContentSections(mainContentRaw);
+1 -1
View File
@@ -1,7 +1,7 @@
import { cleanText } from "./textUtils.js";
const OLLAMA_API_URL = process.env.OLLAMA_API_URL;
export let OLLAMA_MODEL = process.env.OLLAMA_MODEL || "gemma3:latest";
export let OLLAMA_MODEL = process.env.OLLAMA_MODEL || "qwen3.6-35b-a3b";
export async function initializeModel() {
if (process.env.OLLAMA_MODEL) return;