Bound encounter distance by the party's sight line - #31
Merged
Conversation
Encounter distance rolled 2d6 x 10 with no reference to the space it rolled in, so a keyed encounter in a 2x2-cell room could open at 120 feet — six times the room's width. Reported against osr-web as five kobolds watching from eighty feet in a twenty-foot library. The SRD makes the roll a fallback, not the rule: "The situation in which the encounter occurs often determines how far away the monster is. If there is uncertainty, the encounter distance may be determined randomly." The walls the party stands between are that situation, and the engine was skipping the primary clause to reach the tiebreaker. Measured across every keyed encounter in the eight adventures on hand, 96.6% of rolls exceeded the room's own longest side. The rolled distance is now capped at the longest unobstructed straight sight line from the party's cell, taken across the four grid directions through edges sight crosses and floored at one cell. One rule covers a chamber, a corridor, and a spawned encounter alike: a small room clamps, a long passage keeps the full range, and roughly 8% of cells see far enough never to clamp at all. An explicitly supplied distance is never bounded. This is geometry, not illumination. Darkness never shortens the line, because a monster the party cannot see is still exactly as far away as it is; light governs surprise, which is modelled separately. The cap reads the roll's result and never the stream, so the draw sequence is unchanged. Distances in cramped spaces do change, so the phase-4 and phase-5 goldens are regenerated and MILESTONE_SEED is repinned from 203 to 21 — the same milestone, same recovered quest, same 45-command script. Encounters in confined spaces now begin closer and are correspondingly deadlier, which is the honest reading of the rule. Claude-Session: https://claude.ai/code/session_01PjCy2kE4R1Yj85rizkkXpV
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.
Fixes the case reported downstream as osr-web#8: "Monsters placed 80′ away in a room no bigger than 40′ on a side."
The bug
start_encounterrolled 2d6 × 10 with no reference to the space it was rolling in, and none of the threeexploration.pycallers pass a distance. A cell is 10 feet, so a keyed encounter in a 2×2-cell room could open at 120 feet — six times the room's width.The reported encounter is locatable: B3 L1 area 5 "Library", cells
(9,19)…(10,20), a 20′ × 20′ room keyed with five kobolds. Over 500 seeds on the unfixed engine, 98.0% of encounters there opened farther than the room is wide, and 14.6% landed on the exact reported 80′.Across all 208 keyed encounters in the eight adventures on hand (842 entry cells), computed against the 2d6 pmf: 96.6% of rolls exceed the room's longest side, 87.0% exceed the party cell's actual sight line. The example adventure in this repo has it too — a 50′ barrow corridor opening encounters at 90′.
Why it's a rules bug, not a missing clamp
srd/Encounters.md§ Encounter Distance:The roll is the fallback. The walls the party is standing between are "the situation", so the engine was skipping the primary clause and going straight to the tiebreaker.
The rule now implemented
The rolled distance is capped at the longest unobstructed straight sight line from the party's cell, taken across the four grid directions through edges sight crosses, floored at one cell. An explicitly supplied
distance_feetis never bounded.One rule covers a chamber, a corridor, and a spawned encounter. Ceilings in the survey run 10′–220′; about 8% of cells see far enough to never clamp, so long passages keep the full atmospheric range.
Alternatives rejected:
[10, ceiling]— invents a distribution the rules don't have. "The situation determines" is a clamp.Determinism
The cap reads the roll's result and never the stream, so the draw sequence is identical bounded or not — asserted by
test_the_bound_consumes_no_randomnessagainst the exported stream state.Distances in cramped spaces genuinely change, so
phase4_delve.jsonandphase5_milestone.jsonare regenerated andMILESTONE_SEEDis repinned 203 → 21. The new seed reproduces the same milestone: samequest.idol: recovered, same 45-command script, zero deaths.phase5_hoards.jsonandphase5_npc_parties.jsonregenerated byte-identical.Balance
Encounters in confined spaces now begin closer and are correspondingly deadlier — the party loses a round or two of free missile fire before contact. That is the honest reading of the rule and is intended.
Verification
1588 passed, 58 skipped(baseline 1579, +9 new)ruff format --check,ruff check,pyright0 errors,mkdocs build --strictcleanhttps://claude.ai/code/session_01PjCy2kE4R1Yj85rizkkXpV