Generate dungeon entrances when building locations #123

Merged
Copilot merged 2 commits from copilot/generate-dungeon-with-location into update-v0.41.0 2025-11-19 13:02:34 -05:00
Copilot commented 2025-11-18 13:35:29 -05:00 (Migrated from github.com)

Implements automatic dungeon entrance generation during location building. When a zone has a dungeon_config but no existing dungeon, there's a 10% chance that one randomly-selected exit will be replaced with a dungeon entrance.

Changes

Zone tracking

  • Added dungeon attribute to Zone class to prevent duplicate dungeon generation

Dungeon entrance generation

  • New generate_dungeon_entrance() in WorldBuilding class - prompts LLM to create entrance fitting location and dungeon themes
  • Prompt templates: CREATE_DUNGEON_ENTRANCE_PROMPT.txt and DUNGEON_ENTRANCE_TEMPLATE.txt

Location building integration

  • Modified build_location() to accept optional zone parameter
  • Post-generation logic checks conditions (has config, no dungeon, 10% random), then:
    • Picks random exit from location_result.exits
    • Generates DungeonEntrance via LLM
    • Builds dungeon and assigns to zone.dungeon
    • Replaces exit in results

Example usage

# Zone with dungeon config but no dungeon yet
zone_info = {
    'dungeon_config': {
        'name': 'Dark Caves',
        'description': 'Underground cave system',
        'races': ['bat', 'spider'],
        'items': ['torch'],
        'max_depth': 3
    }
}

# 10% chance one exit becomes dungeon entrance
result, spawner = llm_util.build_location(
    location=location,
    exit_location_name='Forest Path',
    zone_info=zone_info,
    zone=zone  # Required for dungeon generation
)

Tests

  • test_generate_dungeon_entrance() - entrance generation
  • test_build_location_with_dungeon_generation() - full integration with mocked random
  • test_build_location_no_dungeon_without_config() - no generation without config
  • test_build_location_no_dungeon_if_already_exists() - prevents duplicate dungeons
Original prompt

This section details on the original issue you should resolve

<issue_title>Generate dungeon together with location</issue_title>
<issue_description>We have dungeon generation code, and code for generating a dungeon config when a Zone is generated.

The next step is to maybe generate a dungeon when a location has been generated.

I think we'll do it here:
LlmUtil.build_location

After build_location has returned a location_result we will check zone_info. If it has a dungeon_config, and it doesn't have a dungeon (these must be added to the class) and at random chance of 0.1, we will do the following:

  • Randomly pick one of the new exits in the location_result
  • Call a new method that prompts to generate a DungeonEntrance. The prompt template should contain the dungeon_config and encourage the LLM to generate a dungeon entrance that adheres to both the dungeon config and the location.
  • Replace the picked exit with the newly created DungeonEntrance.
  • Make tests that verify everything.</issue_description>

<agent_instructions>If possible, look at the recent PRs:
https://github.com/neph1/LlamaTale/pull/120
https://github.com/neph1/LlamaTale/pull/116
that are related to dungeon generation. both are merged into the target branch</agent_instructions>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Implements automatic dungeon entrance generation during location building. When a zone has a `dungeon_config` but no existing dungeon, there's a 10% chance that one randomly-selected exit will be replaced with a dungeon entrance. ## Changes **Zone tracking** - Added `dungeon` attribute to `Zone` class to prevent duplicate dungeon generation **Dungeon entrance generation** - New `generate_dungeon_entrance()` in `WorldBuilding` class - prompts LLM to create entrance fitting location and dungeon themes - Prompt templates: `CREATE_DUNGEON_ENTRANCE_PROMPT.txt` and `DUNGEON_ENTRANCE_TEMPLATE.txt` **Location building integration** - Modified `build_location()` to accept optional `zone` parameter - Post-generation logic checks conditions (has config, no dungeon, 10% random), then: - Picks random exit from `location_result.exits` - Generates `DungeonEntrance` via LLM - Builds dungeon and assigns to `zone.dungeon` - Replaces exit in results **Example usage** ```python # Zone with dungeon config but no dungeon yet zone_info = { 'dungeon_config': { 'name': 'Dark Caves', 'description': 'Underground cave system', 'races': ['bat', 'spider'], 'items': ['torch'], 'max_depth': 3 } } # 10% chance one exit becomes dungeon entrance result, spawner = llm_util.build_location( location=location, exit_location_name='Forest Path', zone_info=zone_info, zone=zone # Required for dungeon generation ) ``` ## Tests - `test_generate_dungeon_entrance()` - entrance generation - `test_build_location_with_dungeon_generation()` - full integration with mocked random - `test_build_location_no_dungeon_without_config()` - no generation without config - `test_build_location_no_dungeon_if_already_exists()` - prevents duplicate dungeons <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Generate dungeon together with location</issue_title> > <issue_description>We have dungeon generation code, and code for generating a dungeon config when a Zone is generated. > > The next step is to _maybe_ generate a dungeon when a location has been generated. > > I think we'll do it here: > LlmUtil.build_location > > After build_location has returned a location_result we will check zone_info. If it has a dungeon_config, and it doesn't have a dungeon (these must be added to the class) and at random chance of 0.1, we will do the following: > > * Randomly pick one of the new exits in the location_result > * Call a new method that prompts to generate a DungeonEntrance. The prompt template should contain the dungeon_config and encourage the LLM to generate a dungeon entrance that adheres to both the dungeon config and the location. > * Replace the picked exit with the newly created DungeonEntrance. > * Make tests that verify everything.</issue_description> > > <agent_instructions>If possible, look at the recent PRs: > https://github.com/neph1/LlamaTale/pull/120 > https://github.com/neph1/LlamaTale/pull/116 > that are related to dungeon generation. both are merged into the target branch</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes neph1/LlamaTale#122 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
neph1 (Migrated from github.com) approved these changes 2025-11-18 14:00:44 -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!123
No description provided.