J. Rogers, SE Ohio
--- START AI VILLAGE GENERATION ---
DEBUG: Gathering building list from current markers...
DEBUG: Found 7 locations: Chapel of the Dawn, Market Square, Village Well, Chapel of the Dawn, Tom's Stables, Margaret Family Farm, Secret Dungeon
==================== AI PROMPT SENT ====================
You are a TTRPG content generator for a fantasy setting. Given the following village, populate it with rich, interconnected details.
Village Name: test (Local)
Key Locations Present: Chapel of the Dawn, Market Square, Village Well, Chapel of the Dawn, Tom's Stables, Margaret Family Farm, Secret Dungeon
Return a single JSON object with this exact structure:
- 'overview': An atmospheric paragraph about the village's history, atmosphere, and current situation.
- 'locations': A dictionary where each key is a location name from the list above, and the value is a one-sentence description for a map tooltip.
- 'npcs': A list of 3-4 notable NPC objects. Each NPC object must have these keys: 'name' (string), 'role' (string, e.g., 'Blacksmith'), 'personality' (string), 'hook' (string, a plot hook related to them), and 'location' (string, MUST be one of the Key Locations provided).
- 'rumors': A list of 4-6 interesting plot hooks or rumors floating around the village.
========================================================
==================== AI RESPONSE RECEIVED ====================
{
"overview": "The village of Local, known simply as 'test' to outsiders, is a secluded agricultural settlement nestled at the foot of the Whisperwood. Founded generations ago by pilgrims dedicated to the Dawn faith, the village maintains a quiet, almost fiercely insular atmosphere. While crops are generally good, a recent series of strange animal disappearances, coupled with the village priest's increasingly erratic behavior, has sown seeds of paranoia among the usually stoic residents, hinting at a corruption deeper than simple mischief.",
"locations": {
"Chapel of the Dawn": "A sturdy stone structure dedicated to the sun god, currently suffering from neglect and radiating an unusual coldness.",
"Market Square": "A dusty, central clearing where local farmers sell goods, currently hosting a solitary, suspicious traveling merchant.",
"Village Well": "The community's primary water source, known for its remarkably cold and clear water, though recent samples have had a slight metallic tang.",
"Tom's Stables": "A ramshackle but operational stable run by the eponymous owner, specializing in sturdy draft horses and unreliable gossip.",
"Margaret Family Farm": "The largest and most prosperous farmstead outside the central village, specializing in grain and wool, run by a demanding matriarch.",
"Secret Dungeon": "A hidden, moss-covered entrance disguised beneath an ancient, oddly scarred oak tree just outside the village boundaries."
},
"npcs": [
{
"name": "Father Elara",
"role": "Priest of the Dawn",
"personality": "Anxious, zealous, and intensely sleep-deprived; he interprets all misfortune as a sign of divine abandonment.",
"hook": "He needs someone discrete to investigate the source of the persistent metallic taste in the well water, believing it is a physical manifestation of a growing spiritual corruption.",
"location": "Chapel of the Dawn"
},
{
"name": "Ma Margaret",
"role": "Farm Matriarch",
"personality": "Tough, skeptical, and fiercely protective; she trusts steel more than prayer.",
"hook": "Her favorite working dog vanished without a sound last night, and she offers a significant bounty (10 gold) for the recovery of the dog or the head of whatever killed it, insisting the tracks lead towards the Secret Dungeon area.",
"location": "Margaret Family Farm"
},
{
"name": "Roric 'Red'",
"role": "Stable Hand/Gossip",
"personality": "Gossipy, slightly cowardly, but observant, always eager to trade information for coin or a drink.",
"hook": "He claims he saw a cloaked figure leaving the Village Well area carrying a heavy sack late one night, and he can be convinced to point out the Secret Dungeon's hidden location if promised anonymity.",
"location": "Tom's Stables"
},
{
"name": "Vess",
"role": "Traveling Apothecary",
"personality": "Smooth-talking and unnervingly knowledgeable about ancient history; he constantly wears heavy leather gloves.",
"hook": "He is selling 'purification salts' guaranteed to cure the metallic taste in the water, but if pressed, he admits the salts are mined from deep subterranean fungi and might cause vivid, disturbing dreams.",
"location": "Market Square"
}
],
"rumors": [
"Someone saw Father Elara secretly dumping something into the Village Well late last night; it looked like shimmering silver dust.",
"The metallic tang in the water only started after the heavy rains exposed strange, unnatural carving marks near the old oak tree (the Secret Dungeon entrance).",
"The reason the village is named 'Local' is because the previous settlement, 'Whisperwatch,' was supposedly wiped out by a sickness that originated in the depths of the earth.",
"Vess the apothecary is paying the local kids small copper pieces to bring him samples of the water from the deepest part of the Village Well, specifically asking for water retrieved after moonrise.",
"Three travelers who asked too many questions about the Secret Dungeon vanished entirely last month; Tom at the stables insists he never boarded them."
]
}
============================================================
--- DATABASE UPDATE ---
DEBUG: Processing 6 location descriptions to update marker tooltips...
-> Updating Marker ID 2 ('Chapel of the Dawn'): new description='A sturdy stone structure dedicated to the sun god, currently suffering from negl...'
-> Updating Marker ID 3 ('Market Square'): new description='A dusty, central clearing where local farmers sell goods, currently hosting a so...'
-> Updating Marker ID 4 ('Village Well'): new description='The community's primary water source, known for its remarkably cold and clear wa...'
-> Updating Marker ID 5 ('Chapel of the Dawn'): new description='A sturdy stone structure dedicated to the sun god, currently suffering from negl...'
-> Updating Marker ID 6 ('Tom's Stables'): new description='A ramshackle but operational stable run by the eponymous owner, specializing in ...'
-> Updating Marker ID 7 ('Margaret Family Farm'): new description='The largest and most prosperous farmstead outside the central village, specializ...'
-> Updating Marker ID 8 ('Secret Dungeon'): new description='A hidden, moss-covered entrance disguised beneath an ancient, oddly scarred oak ...'
CREATE TABLE npcs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
node_id INTEGER NOT NULL,
name TEXT NOT NULL,
role TEXT,
personality TEXT,
hook TEXT,
location TEXT,
metadata TEXT,
FOREIGN KEY(node_id) REFERENCES nodes(id)
);
INSERT INTO npcs VALUES(1,2,'Father Urien','Village Priest of the Dawn','Cold, distracted, obsessive, and plagued by severe insomnia.','He constantly searches for specific symbols in ancient texts, muttering about ''staving off the true night,'' and visibly avoids touching the Holy Brazier.','Chapel of the Dawn','{}');
INSERT INTO npcs VALUES(2,2,'Silas','Traveling Provisioner/Fence','Oily, overly cheerful, highly observant, and deeply mercenary.','He claims to be selling rare herbs, but is actually interested in purchasing any ''unusual metals'' or ''old religious artifacts'' the villagers might find, offering exorbitant prices.','Market Square','{}');
INSERT INTO npcs VALUES(3,2,'Tom','Proprietor of Tom''s Stables','Nervous, overly chatty, easily swayed by bribes, and deeply superstitious about the woods.','He saw someone digging near the scarred oak tree late one night but is too terrified to tell Father Urien, fearing divine retribution for having spied.','Tom''s Stables','{}');
INSERT INTO npcs VALUES(4,2,'Matriarch Margaret','Head of the Margaret Family Farm','Imperious, deeply practical, fiercely protective of her livestock and paranoid about theft.','She believes the disappearances are caused by neighboring thieves, not monsters, and is secretly stockpiling weapons and setting traps in her barns.','Margaret Family Farm','{}');
INSERT INTO npcs VALUES(5,2,'Elara','Hermit/Herbalist','Quiet, cynical, possesses deep knowledge of local folklore, and strongly distrusts the Church''s authority.','She uses the Village Well water for her medicinal mixtures and confirms the metallic tang, suggesting it is a poison linked to something ancient stirring beneath the Whisperwood.','Village Well','{}');
INSERT INTO npcs VALUES(6,2,'Joren','Father Urien''s Apprentice','Mousy, loyal but constantly terrified, prone to crying under pressure.','Joren found a strange, non-human bone fragment near the Chapel altar and hid it in a sack of feed at the stables, hoping Tom knows what creature it came from.','Tom''s Stables','{}');
DEBUG: Storing overview, 4 NPCs, and 5 rumors in Node ID 2's metadata.
--- REFRESHING VIEW ---
--- END AI VILLAGE GENERATION ---
Dev Log: Architectural Refinement & First-Pass AI Integration
1. Graphical & UI Enhancements
Procedural Marker Rendering: The previous system relied on system emoji fonts, which proved unreliable and often rendered as empty boxes []. This was replaced with a procedural drawing system within map_viewer.py. Markers are now drawn as distinct geometric shapes (squares for dungeons, pentagons for buildings, circles for generic points), ensuring they are always visible.On-Map Labels: Marker titles are now rendered directly on the map below the icon. This provides immediate context without requiring a mouse hover, making the map far more readable at a glance.Refined Tooltips: Tooltip functionality was corrected to display the marker's description field, serving as the "public" information for a location. The redundant title was removed, decluttering the hover-over experience.
2. Deep Navigation & Hierarchical Structure
Layer 3 Stub Implementation: The navigation system, which previously halted at the "Local Map" (Layer 2), has been unlocked. The application now correctly generates a new, empty battle_map or dungeon node when a marker on a local map is entered.Black Screen ("The Canvas"): Entering this third layer currently presents a black screen. This is the expected and correct behavior. This black screen represents the "canvas" upon which the TacticalGenerator and a future BattleMapStrategy renderer will draw grid-based interior and dungeon maps.Correct Parent-Child Navigation: The go_up_level function was fixed. It now correctly queries the database for a node's specific parent_node_id, allowing the user to press ESC to navigate seamlessly from a Battle Map back to its parent Local Map, and from the Local Map back to the World Map.
3. Decoupled AI Service Integration
AIManager (The Dumb Pipe): An AIManager class was implemented in the core logic. Its sole responsibility is to handle API authentication and the transport of a prompt string to the configured AI service (currently Gemini), and to return a parsed JSON object. It has no knowledge of game-specific concepts like "villages" or "NPCs."VillageContentManager (The Caller): To properly separate concerns, the logic for generating village details was moved out of the UI layer and into its own dedicated "caller" class. This class is responsible for:Gathering all existing context from the database (building names, existing NPC data). Constructing a detailed, context-aware prompt that instructs the AI to enhance, not overwrite, existing data. Calling the AIManager to get a JSON response. Intelligently persisting the response by updating individual marker descriptions and storing high-level data (NPCs, rumors) in the correct database tables.
Result - A Working Data Pipeline: We have successfully demonstrated a complete, end-to-end data pipeline. A user can now:Navigate to a procedurally generated local map. Click a single "AI Gen Village Details" button. Trigger a context-aware AI query. Receive structured JSON data back. Have that data automatically and correctly persisted into the nodes, markers, and npcs tables of the SQLite database.
4. Native Metadata Editor
Real Text Editing: The NativeMarkerEditor provides a robust, multi-line text editor for descriptions and a dedicated editor for raw JSON metadata, allowing for easy copy-pasting and management of complex data structures.Context-Aware Fields: The editor is now context-aware, presenting different "Type" options depending on whether it is opened on the World Map ("Village") or a Local Map ("Building").Direct AI Trigger: The editor includes the "AI Generate Details" button, providing a direct, entity-specific entry point for content generation that is separate from the holistic village generation.
No comments:
Post a Comment