feat(scengen): EnemyVisitor + ItemVisitor for distance-based content#48
Merged
feat(scengen): EnemyVisitor + ItemVisitor for distance-based content#48
Conversation
…placement New visitors populate scenarios with enemies and items based on graph distance from start: EnemyVisitor: - 5-tier enemy progression (rat → goblin → skeleton → troll → dragon) - Distance-based tier mapping: deeper rooms get harder enemies - 40% spawn rate, skips hub corridors and start room - ±1 tier jitter for variety - TotalXP(), EnemyCount(), MaxTierName() utility functions ItemVisitor: - 5-tier item progression (dagger → sword → longsword → axe → vorpal) - Matching armor tiers (leather → chain → plate → dragon scale) - Healing potions scale with depth (1d6 → 2d6 → 3d6 → 4d6 → 6d6) - Starter weapon at distance 1, starter potion at start room - Potions at high-degree hubs (rest stops) - DefaultSpells() adds fireball, heal, lightning, blessing Graph.MaxDistance() added for normalizing tier assignment. crypt-admin generate now wires all 3 visitors (description → enemy → item) and prints room/enemy/XP/item counts. Balance results (200 sessions, 38-room generated dungeon): 61% survival, level 2.0, 10pp class spread (54-64%) New make targets: generate-dungeon, validate-dungeon, eval-balance-generated, eval-balance-unix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds distance-based population to the scenario generation pipeline so crypt-admin generate can produce larger, balance-testable dungeons with scaled enemies/items and a default spell catalog.
Changes:
- Introduces
EnemyVisitorandItemVisitorto place tiered enemies/items using BFS distance from the start (plus hub-aware rules). - Adds
Graph.MaxDistance()for max BFS depth (tier normalization). - Wires new visitors into
crypt-admin generate, adds Makefile targets for generating/validating/evaluating generated scenarios, and updates bead status.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/scengen/enemy_visitor.go | New visitor that places enemies by distance tier with optional spawn rate and jitter. |
| internal/scengen/enemy_visitor_test.go | Tests for enemy placement, hub skipping, scaling, and spawn-rate edge cases. |
| internal/scengen/item_visitor.go | New visitor that places starter gear, tiered items, hub potions, and (optionally) default spells. |
| internal/scengen/item_visitor_test.go | Tests for starter weapon/potion placement, hubs, spell inclusion, and basic distribution. |
| internal/scengen/graph.go | Adds MaxDistance() BFS helper for tier normalization. |
| cmd/crypt-admin/main.go | Runs description → enemies → items visitors during generation and prints basic stats. |
| Makefile | Adds dungeon generation/validation and balance-eval convenience targets. |
| .beads/issues.jsonl | Updates issue statuses reflecting the scenario-gen work in progress/complete. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
- Guard dist <= 0 in EnemyVisitor (prevents panic on unreachable nodes) - Guard dist < 0 in ItemVisitor with skip (same issue) - Sort nodes by distance then ID for deterministic placement - Seed Rng in crypt-admin generate/export (was nondeterministic) - Wire all 3 visitors into runExport (was only DescriptionVisitor) - SpawnRate: 0 now means no enemies; negative means use default (0.4) - Update SpawnRate comment to match code (was 0.6, is 0.4) - Document visitor ordering dependency (items after enemies) - Add unreachable-node test for EnemyVisitor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
crypt-admin generatenow wires all 3 visitors and prints stats.generate-dungeon,validate-dungeon,eval-balance-generated,eval-balance-unix.Balance results
38-room generated dungeon, 200 sessions:
Test plan
make generate-dungeon→make validate-dungeon→make eval-balance-generatedmake check)🤖 Generated with Claude Code
Note
Medium Risk
Introduces new procedural content generation logic (enemy/item placement and spell catalogs) and changes
crypt-admin generate/exportoutput, which can affect scenario balance and downstream validation but does not touch gameplay engine or auth/security code.Overview
Adds distance-based content generation to
internal/scengenby introducingEnemyVisitor(tiered enemy placement with spawn-rate/jitter, hub skipping) andItemVisitor(tiered weapons/armor/potions plus optional default spell catalog), plus helper metrics likeTotalXP/EnemyCount.Extends
GraphwithMaxDistance()to normalize distance→tier mapping, and updatescrypt-admin generate/exportto run visitors indescription → enemy → itemorder with a seeded RNG and to print basic generation stats.Updates build tooling/docs: new Makefile targets for generating/validating a local dungeon tree and running balance evals on generated and
unix-catacombsscenarios;CHANGELOG.mdand.beads/issues.jsonlreflect the new visitors and related task status.Written by Cursor Bugbot for commit 183b2e8. This will update automatically on new commits. Configure here.