This commit is contained in:
@@ -36,8 +36,8 @@ export async function generateDungeon() {
|
||||
console.log("Starting compact dungeon generation with debug logs...\n");
|
||||
|
||||
// Step 1: Titles
|
||||
const titles10Raw = await callOllama(
|
||||
`Generate 10 short, punchy dungeon titles (max 5 words each), numbered as a plain text list.
|
||||
const generatedTitlesRaw = await callOllama(
|
||||
`Generate 50 short, punchy dungeon titles (max 5 words each), numbered as a plain text list.
|
||||
Each title should come from a different style or theme. Make the set varied and evocative. For example:
|
||||
|
||||
- OSR / classic tabletop: gritty, mysterious, old-school
|
||||
@@ -47,45 +47,24 @@ Each title should come from a different style or theme. Make the set varied and
|
||||
- Weird fantasy: uncanny, surreal, unsettling
|
||||
- Whimsical: fun, quirky, playful
|
||||
|
||||
Avoid repeating materials or adjectives. Do not include any titles with the words "Obsidian" or "Clockwork". Do not include explanations, markdown, or preambles. Do not include the style or theme in parenthesis. Only the 10 numbered titles.`,
|
||||
Avoid repeating materials or adjectives. Absolutely do not use the words "Obsidian" or "Clockwork" in any title. If a title contains either word, it is invalid and must be discarded. Do not include explanations, markdown, or preambles. Do not include the style or theme in parenthesis. Only the 50 numbered titles.`,
|
||||
undefined, 5, "Step 1: Titles"
|
||||
);
|
||||
const titles10 = parseList(titles10Raw, 30);
|
||||
console.log("Parsed titles10:", titles10);
|
||||
|
||||
// Step 2: Narrow to 5
|
||||
const titles5Raw = await callOllama(
|
||||
`Here are 10 dungeon titles:
|
||||
${titles10.join("\n")}
|
||||
|
||||
Randomly select 3 of the titles from the above list and create 2 additional unique titles. Do not include any titles with the words "Obsidian" or "Clockwork".
|
||||
Output exactly 5 titles as a numbered list, plain text only. No explanations.`,
|
||||
undefined, 5, "Step 2: Narrow Titles"
|
||||
);
|
||||
const titles5 = parseList(titles5Raw, 30);
|
||||
console.log("Parsed titles5:", titles5);
|
||||
|
||||
// Step 3: Final title
|
||||
const bestTitleRaw = await callOllama(
|
||||
`From the following 5 dungeon titles, randomly select only one of them.
|
||||
Output only the title, no explanation, no numbering, no extra text:
|
||||
|
||||
${titles5.join("\n")}`,
|
||||
undefined, 5, "Step 3: Final Title"
|
||||
);
|
||||
const title = cleanText(bestTitleRaw.split("\n")[0]);
|
||||
const generatedTitles = parseList(generatedTitlesRaw);
|
||||
console.log("Generated Titles:", generatedTitles);
|
||||
const title = generatedTitles[Math.floor(Math.random() * generatedTitles.length)];
|
||||
console.log("Selected title:", title);
|
||||
|
||||
// Step 4: Flavor text
|
||||
// Step 2: Flavor text
|
||||
const flavorRaw = await callOllama(
|
||||
`Write a single evocative paragraph describing the location titled "${title}".
|
||||
Do not include hooks, NPCs, treasure, or instructions. Do not use bullet points or em-dashes. Output plain text only, one paragraph. Maximum 4 sentences.`,
|
||||
undefined, 5, "Step 4: Flavor"
|
||||
undefined, 5, "Step 2: Flavor"
|
||||
);
|
||||
const flavor = flavorRaw;
|
||||
console.log("Flavor text:", flavor);
|
||||
|
||||
// Step 5: Hooks & Rumors
|
||||
// Step 3: Hooks & Rumors
|
||||
const hooksRumorsRaw = await callOllama(
|
||||
`Based only on this location's flavor:
|
||||
|
||||
@@ -94,12 +73,12 @@ ${flavor}
|
||||
Generate 3 short adventure hooks or rumors (mix them naturally).
|
||||
Output as a single numbered list, plain text only. Do not use em-dashes.
|
||||
Maximum 2 sentences per item. No explanations or extra text.`,
|
||||
undefined, 5, "Step 5: Hooks & Rumors"
|
||||
undefined, 5, "Step 3: Hooks & Rumors"
|
||||
);
|
||||
const hooksRumors = parseList(hooksRumorsRaw, 120);
|
||||
const hooksRumors = parseList(hooksRumorsRaw);
|
||||
console.log("Hooks & Rumors:", hooksRumors);
|
||||
|
||||
// Step 6: Rooms & Encounters
|
||||
// Step 4: Rooms & Encounters
|
||||
const roomsEncountersRaw = await callOllama(
|
||||
`Using the flavor and these hooks/rumors:
|
||||
|
||||
@@ -111,7 +90,7 @@ ${hooksRumors.join("\n")}
|
||||
|
||||
Generate 5 rooms (name + short description) and 6 encounters (name + details).
|
||||
Output two numbered lists, labeled "Rooms:" and "Encounters:". Plain text only. No extra explanation.`,
|
||||
undefined, 5, "Step 6: Rooms & Encounters"
|
||||
undefined, 5, "Step 4: Rooms & Encounters"
|
||||
);
|
||||
const [roomsSection, encountersSection] = roomsEncountersRaw.split(/Encounters[:\n]/i);
|
||||
const rooms = parseObjects(roomsSection.replace(/Rooms[:\n]*/i, ""), "rooms", 120);
|
||||
@@ -119,7 +98,7 @@ Output two numbered lists, labeled "Rooms:" and "Encounters:". Plain text only.
|
||||
console.log("Rooms:", rooms);
|
||||
console.log("Encounters:", encounters);
|
||||
|
||||
// Step 7: Treasure & NPCs
|
||||
// Step 5: Treasure & NPCs
|
||||
const treasureNpcsRaw = await callOllama(
|
||||
`Based only on these rooms and encounters:
|
||||
|
||||
@@ -129,15 +108,15 @@ Generate 3 treasures and 3 NPCs (name + trait, max 2 sentences each).
|
||||
Each NPC has a proper name, not just a title.
|
||||
Treasure should sometimes include a danger or side-effect.
|
||||
Output numbered lists labeled "Treasure:" and "NPCs:". Plain text only, no extra text.`,
|
||||
undefined, 5, "Step 7: Treasure & NPCs"
|
||||
undefined, 5, "Step 5: Treasure & NPCs"
|
||||
);
|
||||
const [treasureSection, npcsSection] = treasureNpcsRaw.split(/NPCs[:\n]/i);
|
||||
const treasure = parseList(treasureSection.replace(/Treasures?[:\n]*/i, ""), 120);
|
||||
const treasure = parseList(treasureSection.replace(/Treasures?[:\n]*/i, ""));
|
||||
const npcs = parseObjects(npcsSection || "", "npcs", 120);
|
||||
console.log("Treasure:", treasure);
|
||||
console.log("NPCs:", npcs);
|
||||
|
||||
// Step 8: Plot Resolutions
|
||||
// Step 6: Plot Resolutions
|
||||
const plotResolutionsRaw = await callOllama(
|
||||
`Based on the following location's flavor and story hooks:
|
||||
|
||||
@@ -155,9 +134,9 @@ These are prompts and ideas for brainstorming the story's ending, not fixed outc
|
||||
Start each item with phrases like "The adventurers could" or "The PCs might" to emphasize their hypothetical nature.
|
||||
Deepen the narrative texture and allow roleplay and tactical creativity.
|
||||
Keep each item short (max 2 sentences). Output as a numbered list, plain text only.`,
|
||||
undefined, 5, "Step 8: Plot Resolutions"
|
||||
undefined, 5, "Step 6: Plot Resolutions"
|
||||
);
|
||||
const plotResolutions = parseList(plotResolutionsRaw, 180);
|
||||
const plotResolutions = parseList(plotResolutionsRaw);
|
||||
console.log("Plot Resolutions:", plotResolutions);
|
||||
|
||||
console.log("\nDungeon generation complete!");
|
||||
|
||||
Reference in New Issue
Block a user