improve gen
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

This commit is contained in:
Madison Grubb
2025-09-05 13:18:24 -04:00
parent 800c9c488c
commit d436284476
3 changed files with 199 additions and 162 deletions

View File

@@ -36,8 +36,8 @@ export async function generateDungeon() {
console.log("Starting compact dungeon generation with debug logs...\n"); console.log("Starting compact dungeon generation with debug logs...\n");
// Step 1: Titles // Step 1: Titles
const titles10Raw = await callOllama( const generatedTitlesRaw = await callOllama(
`Generate 10 short, punchy dungeon titles (max 5 words each), numbered as a plain text list. `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: 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 - 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 - Weird fantasy: uncanny, surreal, unsettling
- Whimsical: fun, quirky, playful - 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" undefined, 5, "Step 1: Titles"
); );
const titles10 = parseList(titles10Raw, 30); const generatedTitles = parseList(generatedTitlesRaw);
console.log("Parsed titles10:", titles10); console.log("Generated Titles:", generatedTitles);
const title = generatedTitles[Math.floor(Math.random() * generatedTitles.length)];
// 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]);
console.log("Selected title:", title); console.log("Selected title:", title);
// Step 4: Flavor text // Step 2: Flavor text
const flavorRaw = await callOllama( const flavorRaw = await callOllama(
`Write a single evocative paragraph describing the location titled "${title}". `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.`, 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; const flavor = flavorRaw;
console.log("Flavor text:", flavor); console.log("Flavor text:", flavor);
// Step 5: Hooks & Rumors // Step 3: Hooks & Rumors
const hooksRumorsRaw = await callOllama( const hooksRumorsRaw = await callOllama(
`Based only on this location's flavor: `Based only on this location's flavor:
@@ -94,12 +73,12 @@ ${flavor}
Generate 3 short adventure hooks or rumors (mix them naturally). Generate 3 short adventure hooks or rumors (mix them naturally).
Output as a single numbered list, plain text only. Do not use em-dashes. Output as a single numbered list, plain text only. Do not use em-dashes.
Maximum 2 sentences per item. No explanations or extra text.`, 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); console.log("Hooks & Rumors:", hooksRumors);
// Step 6: Rooms & Encounters // Step 4: Rooms & Encounters
const roomsEncountersRaw = await callOllama( const roomsEncountersRaw = await callOllama(
`Using the flavor and these hooks/rumors: `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). 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.`, 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 [roomsSection, encountersSection] = roomsEncountersRaw.split(/Encounters[:\n]/i);
const rooms = parseObjects(roomsSection.replace(/Rooms[:\n]*/i, ""), "rooms", 120); 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("Rooms:", rooms);
console.log("Encounters:", encounters); console.log("Encounters:", encounters);
// Step 7: Treasure & NPCs // Step 5: Treasure & NPCs
const treasureNpcsRaw = await callOllama( const treasureNpcsRaw = await callOllama(
`Based only on these rooms and encounters: `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. Each NPC has a proper name, not just a title.
Treasure should sometimes include a danger or side-effect. Treasure should sometimes include a danger or side-effect.
Output numbered lists labeled "Treasure:" and "NPCs:". Plain text only, no extra text.`, 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 [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); const npcs = parseObjects(npcsSection || "", "npcs", 120);
console.log("Treasure:", treasure); console.log("Treasure:", treasure);
console.log("NPCs:", npcs); console.log("NPCs:", npcs);
// Step 8: Plot Resolutions // Step 6: Plot Resolutions
const plotResolutionsRaw = await callOllama( const plotResolutionsRaw = await callOllama(
`Based on the following location's flavor and story hooks: `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. 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. 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.`, 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("Plot Resolutions:", plotResolutions);
console.log("\nDungeon generation complete!"); console.log("\nDungeon generation complete!");

View File

@@ -11,8 +11,10 @@ export function dungeonTemplate(data) {
]; ];
const headingFonts = [ const headingFonts = [
"'New Rocker', system-ui",
"'UnifrakturCook', cursive",
"'IM Fell DW Pica', serif",
"'Cinzel', serif", "'Cinzel', serif",
"'MedievalSharp', serif",
"'Cormorant Garamond', serif", "'Cormorant Garamond', serif",
"'Playfair Display', serif" "'Playfair Display', serif"
]; ];
@@ -26,7 +28,6 @@ export function dungeonTemplate(data) {
const quoteFonts = [ const quoteFonts = [
"'Playfair Display', serif", "'Playfair Display', serif",
"'Uncial Antiqua', serif",
"'Libre Baskerville', serif", "'Libre Baskerville', serif",
"'Merriweather', serif" "'Merriweather', serif"
]; ];
@@ -40,127 +41,184 @@ export function dungeonTemplate(data) {
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>${data.title}</title> <title>${data.title}</title>
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative&family=MedievalSharp&family=Metamorphous&family=Playfair+Display&family=Alegreya+Sans&family=Cabin&family=IBM+Plex+Sans&family=Cormorant+Garamond&family=Lora&family=Merriweather&family=Libre+Baskerville&family=Source+Serif+4&family=Walter+Turncoat&family=Uncial+Antiqua&family=Beth+Ellen&family=Pinyon+Script&display=swap" rel="stylesheet"> <link
<style> href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative&family=UnifrakturCook&family=New+Rocker&family=Metamorphous&family=Playfair+Display&family=Alegreya+Sans&family=Cabin&family=IBM+Plex+Sans&family=Cormorant+Garamond&family=Lora&family=Merriweather&family=Libre+Baskerville&family=Source+Serif+4&family=Walter+Turncoat&family=Uncial+Antiqua&family=Beth+Ellen&family=Pinyon+Script&display=swap"
@page { size: A4 landscape; margin: 0; } rel="stylesheet">
body { <style>
margin: 0; padding: 1.5cm; @page {
background: #f5f5f5; size: A4 landscape;
font-family: ${bodyFont}; margin: 0;
color: #1a1a1a; }
font-size: 0.7em; body {
line-height: 1.25em; margin: 0;
} padding: 0;
h1 { font-family: ${bodyFont};
font-family: ${headingFont}; color: #1a1a1a;
text-align: center; font-size: 0.7em;
font-size: 2em; line-height: 1.25em;
margin: 0.2em 0 0.3em; }
color: #1a1a1a; .content-page {
border-bottom: 2px solid #1a1a1a; height: 100vh;
padding-bottom: 0.2em; box-sizing: border-box;
letter-spacing: 0.1em; padding: 1.5cm;
} page-break-after: always;
.flavor { overflow: hidden;
text-align: center; break-inside: avoid;
font-style: italic; }
font-family: ${quoteFont}; h1 {
margin: 0.4em 0 0.8em; font-family: ${headingFont};
font-size: 0.9em; text-align: center;
} font-size: 2em;
.columns { margin: 0.2em 0 0.3em;
display: grid; color: #1a1a1a;
grid-template-columns: 1fr 1fr 1fr; border-bottom: 2px solid #1a1a1a;
gap: 0.5cm; padding-bottom: 0.2em;
align-items: start; letter-spacing: 0.1em;
} }
.col { .flavor {
display: flex; flex-direction: column; text-align: center;
gap: 0.15em; font-style: italic;
} font-family: ${quoteFont};
h2 { margin: 0.4em 0 0.8em;
font-family: ${headingFont}; font-size: 0.9em;
font-size: 1.0em; }
margin: 0.3em 0 0.1em; .columns {
color: #1a1a1a; display: grid;
border-bottom: 1px solid #1a1a1a; grid-template-columns: 1fr 1fr 1fr;
padding-bottom: 0.1em; gap: 0.5cm;
text-transform: uppercase; align-items: start;
letter-spacing: 0.05em; }
} .col {
.room h3 { margin: 0.2em 0 0.05em; font-size: 0.95em; font-weight: bold; } display: flex;
.room p { text-align: justify; word-wrap: break-word; margin: 0.1em 0 0.3em; } flex-direction: column;
ul { padding-left: 1em; margin: 0.1em 0 0.3em; } gap: 0.15em;
li { margin-bottom: 0.2em; } }
table { width: 100%; border-collapse: collapse; font-family: ${tableFont}; font-size: 0.8em; } h2 {
th, td { border: 1px solid #1a1a1a; padding: 0.2em; text-align: left; vertical-align: top; } font-family: ${headingFont};
th { background: #e0e0e0; } font-size: 1.0em;
table tr:hover { background: rgba(0, 0, 0, 0.05); } margin: 0.3em 0 0.1em;
.map-page { color: #1a1a1a;
page-break-before: always; border-bottom: 1px solid #1a1a1a;
display: flex; padding-bottom: 0.1em;
align-items: center; text-transform: uppercase;
justify-content: center; letter-spacing: 0.05em;
padding: 1.5cm; }
height: calc(100vh - 3cm); .room h3 {
box-sizing: border-box; margin: 0.2em 0 0.05em;
background: #f5f5f5; font-size: 0.95em;
} font-weight: bold;
.map-page img { }
max-width: 100%; .room p {
max-height: 100%; text-align: justify;
height: auto; word-wrap: break-word;
width: auto; margin: 0.1em 0 0.3em;
border-radius: 0.2cm; }
object-fit: contain; ul {
box-shadow: padding-left: 1em;
0 0 20px 15px #f5f5f5 inset, margin: 0.1em 0 0.3em;
0 0 5px 2px rgba(0, 0, 0, 0.05); }
} li {
footer { margin-bottom: 0.2em;
text-align: center; font-size: 0.65em; color: #555; margin-top: 0.5em; font-style: italic; }
} table {
</style> width: 100%;
border-collapse: collapse;
font-family: ${tableFont};
font-size: 0.8em;
}
th,
td {
border: 1px solid #1a1a1a;
padding: 0.2em;
text-align: left;
vertical-align: top;
}
th {
background: #e0e0e0;
}
table tr:hover {
background: rgba(0, 0, 0, 0.05);
}
.map-page {
height: 210mm;
width: 297mm;
box-sizing: border-box;
padding: 1.5cm;
position: relative;
display: block;
}
.map-image-container {
position: absolute;
top: 1.5cm;
left: 1.5cm;
right: 1.5cm;
bottom: 3cm;
display: flex;
align-items: center;
justify-content: center;
}
.map-page img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.map-page footer {
position: absolute;
bottom: 1.5cm;
left: 1.5cm;
right: 1.5cm;
text-align: center;
font-size: 0.65em;
color: #555;
font-style: italic;
}
</style>
</head> </head>
<body> <body>
<h1>${data.title}</h1> <div class="content-page">
<p class="flavor">${data.flavor}</p> <h1>${data.title}</h1>
<p class="flavor">${data.flavor}</p>
<div class="columns"> <div class="columns">
<div class="col"> <div class="col">
<h2>Adventure Hooks & Rumors</h2> <h2>Adventure Hooks & Rumors</h2>
<ul>${data.hooksRumors.map(item => `<li>${item}</li>`).join("")}</ul> <ul>${data.hooksRumors.map(item => `<li>${item}</li>`).join("")}</ul>
<h2>Locations</h2>
<h2>Locations</h2> ${data.rooms.map((room, i) => `<div class="room">
${data.rooms.map((room, i) => `<div class="room"><h3>${i + 1}. ${room.name}</h3><p>${room.description}</p></div>`).join("")} <h3>${i + 1}. ${room.name}</h3>
<p>${room.description}</p>
</div>`).join("")}
</div>
<div class="col">
<h2>Encounters</h2>
<table>
<tr>
<th>Name</th>
<th>Details</th>
</tr>
${data.encounters.map(e => `<tr>
<td>${e.name}</td>
<td>${e.details}</td>
</tr>`).join("")}
</table>
<h2>Treasure</h2>
<ul>${data.treasure.map(t => `<li>${t}</li>`).join("")}</ul>
</div>
<div class="col">
<h2>NPCs</h2>
<ul>${data.npcs.map(n => `<li><b>${n.name}</b>: ${n.trait}</li>`).join("")}</ul>
<h2>Plot Resolutions</h2>
<ul>${data.plotResolutions.map(p => `<li>${p}</li>`).join("")}</ul>
</div>
</div>
</div> </div>
<div class="map-page">
<div class="col"> <div class="map-image-container">
<h2>Encounters</h2> <img src="${data.map}" alt="Dungeon Map">
<table><tr><th>Name</th><th>Details</th></tr> </div>
${data.encounters.map(e => `<tr><td>${e.name}</td><td>${e.details}</td></tr>`).join("")} <footer>Generated with Scrollsmith • © ${new Date().getFullYear()}</footer>
</table>
<h2>Treasure</h2>
<ul>${data.treasure.map(t => `<li>${t}</li>`).join("")}</ul>
</div> </div>
<div class="col">
<h2>NPCs</h2>
<ul>${data.npcs.map(n => `<li><b>${n.name}</b>: ${n.trait}</li>`).join("")}</ul>
<h2>Plot Resolutions</h2>
<ul>${data.plotResolutions.map(p => `<li>${p}</li>`).join("")}</ul>
</div>
</div>
<div class="map-page">
<img src="${data.map}" alt="Dungeon Map">
</div>
<footer>Generated with Scrollsmith • © ${new Date().getFullYear()}</footer>
</body> </body>
</html> </html>
`; `;

View File

@@ -51,7 +51,7 @@ function buildComfyWorkflow(promptText, negativeText = "") {
"inputs": { "inputs": {
"seed": Math.floor(Math.random() * 100000), "seed": Math.floor(Math.random() * 100000),
"steps": 4, "steps": 4,
"cfg": 2, "cfg": 1,
"sampler_name": "euler", "sampler_name": "euler",
"scheduler": "simple", "scheduler": "simple",
"denoise": 1, "denoise": 1,
@@ -71,8 +71,8 @@ function buildComfyWorkflow(promptText, negativeText = "") {
}, },
"5": { "5": {
"inputs": { "inputs": {
"width": 640, "width": 848,
"height": 448, "height": 600,
"batch_size": 1 "batch_size": 1
}, },
"class_type": "EmptyLatentImage" "class_type": "EmptyLatentImage"