Add dungeon config generation to zone creation with 10% probability #120

Merged
Copilot merged 2 commits from copilot/generate-dungeon-config-in-worldbuilding into update-v0.41.0 2025-11-18 13:22:25 -05:00
Copilot commented 2025-11-16 12:05:45 -05:00 (Migrated from github.com)

Dungeons now generate configuration data automatically during zone creation. When a new zone is generated in get_neighbor_or_generate_zone, there's a 10% chance a dungeon config is created via LLM.

Changes

New LlmRequest class: GenerateDungeonConfig

  • Builds prompts from zone info (theme, level, mood, races, items)
  • Located at tale/llm/requests/generate_dungeon_config.py

Prompt templates:

  • CREATE_DUNGEON_CONFIG_PROMPT.txt - Instructs LLM to generate dungeon fitting zone context
  • DUNGEON_CONFIG_TEMPLATE.txt - JSON schema for dungeon properties (name, description, races, items, max_depth)

WorldBuilding integration:

  • Added _generate_dungeon_config() method to handle LLM request and DungeonConfig deserialization
  • Modified get_neighbor_or_generate_zone() to call dungeon generation at 10% probability after successful zone creation
  • Gracefully handles LLM failures (returns None, zone creation still succeeds)

Example

# In get_neighbor_or_generate_zone, after zone is validated and added:
if zone and story.add_zone(zone):
    zone.level = (zone.level + 1) if random.random() < 0.5 else zone.level
    # Generate dungeon config at 10% chance
    if random.random() < 0.1:
        dungeon_config = self._generate_dungeon_config(zone, world_generation_context)
        if dungeon_config:
            zone.dungeon_config = dungeon_config
    return zone

The generated dungeon config is serialized with the zone via existing Zone.get_info() / from_json() mechanisms.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dungeon config generation</issue_title>
<issue_description>We have one step left for dungeons to be usable for all stories.. A dungeon config needs to be generated if a Zone should have a dungeon.
I think we should jack into get_neighbor_or_generate_zone in WorldBuilding.

  • After the zone has been generated, at a 10% chance, a dungeon config should also be generated in a separate call.
  • Create a new class extending LlmRequest to handle this.
  • Add a new prompt template for dungeon config generation (preliminary content)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Dungeons now generate configuration data automatically during zone creation. When a new zone is generated in `get_neighbor_or_generate_zone`, there's a 10% chance a dungeon config is created via LLM. ## Changes **New LlmRequest class**: `GenerateDungeonConfig` - Builds prompts from zone info (theme, level, mood, races, items) - Located at `tale/llm/requests/generate_dungeon_config.py` **Prompt templates**: - `CREATE_DUNGEON_CONFIG_PROMPT.txt` - Instructs LLM to generate dungeon fitting zone context - `DUNGEON_CONFIG_TEMPLATE.txt` - JSON schema for dungeon properties (name, description, races, items, max_depth) **WorldBuilding integration**: - Added `_generate_dungeon_config()` method to handle LLM request and DungeonConfig deserialization - Modified `get_neighbor_or_generate_zone()` to call dungeon generation at 10% probability after successful zone creation - Gracefully handles LLM failures (returns None, zone creation still succeeds) ## Example ```python # In get_neighbor_or_generate_zone, after zone is validated and added: if zone and story.add_zone(zone): zone.level = (zone.level + 1) if random.random() < 0.5 else zone.level # Generate dungeon config at 10% chance if random.random() < 0.1: dungeon_config = self._generate_dungeon_config(zone, world_generation_context) if dungeon_config: zone.dungeon_config = dungeon_config return zone ``` The generated dungeon config is serialized with the zone via existing `Zone.get_info()` / `from_json()` mechanisms. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Dungeon config generation</issue_title> > <issue_description>We have one step left for dungeons to be usable for all stories.. A dungeon config needs to be generated if a Zone should have a dungeon. > I think we should jack into get_neighbor_or_generate_zone in WorldBuilding. > * After the zone has been generated, at a 10% chance, a dungeon config should also be generated in a separate call. > * Create a new class extending LlmRequest to handle this. > * Add a new prompt template for dungeon config generation (preliminary content)</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes neph1/LlamaTale#119 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
neph1 (Migrated from github.com) approved these changes 2025-11-18 13:22:18 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
neph1/LlamaTale!120
No description provided.