Skip to content

themerms: keep Teleportation hub traps off the wall-adjacent gutter - #1641

Open
davidbau wants to merge 1 commit into
NetHack:NetHack-5.0from
davidbau:teleport-hub-gutter
Open

davidbau wants to merge 1 commit into
NetHack:NetHack-5.0from
davidbau:teleport-hub-gutter

Conversation

@davidbau

Copy link
Copy Markdown
Contributor

A fix for #1640.

The Teleportation hub fill scatters 2-4 "fixed-destination" teleport traps across a room's whole floor. An unlucky room can end up with traps on every tile in front of its only doorway, all teleporting to the far side of the level, leaving no trap-free way through the room. (See #1640 for an example. Level connectivity is built assuming every room is freely passable, so a bad arrangement of fixed-teleport traps can make the level impassable.)

The change places the traps on the room's interior only, never the perimeter "gutter" of floor tiles next to a wall. A clear gutter always leaves a trap-free walk around the room's edge between every door. The trap count is capped at the number of interior tiles, so small rooms place fewer traps and a room with no interior places none.

@davidbau
davidbau force-pushed the teleport-hub-gutter branch 2 times, most recently from f72b395 to 23eb0d1 Compare July 26, 2026 09:51
The Teleportation hub fill scatters 2-4 fixed-destination teleport
traps across a room's whole floor. Because each destination is fixed at
generation, an unlucky room can end up with traps on every tile in
front of its only doorway, all teleporting to the far side of the
level, leaving no trap-free way through the room. Level connectivity is
built assuming every room is freely passable and is never rechecked
after traps are placed, so this slips through.

Place the traps on the room's interior only, never the perimeter
"gutter" of floor tiles next to a wall. A clear gutter always leaves a
trap-free walk around the room's edge between every door. The trap
count is capped at the number of interior tiles, so small rooms place
fewer traps and a room with no interior places none.

Tested in a local wizard-mode build with THEMERMFILL forcing the hub
onto every room: traps land only on interior tiles and every doorway
stays walkable. Claude assisted with getting the selection-API Lua
right.
@ars3niy

ars3niy commented Aug 7, 2026 •

Copy link
Copy Markdown

I believe one can have this weaker set of constraints instead:

  • a teleporter in the corner of the room cannot have another teleporter grid-bug-adjacent to it (i.e. vertically or horizontally);
  • a "grid-bug-connected" set of teleporters, i.e. a set where a grid bug can travel from any one to any other while staying within the set, cannot contain two teleporters that are on the edge of the room and not grid-bug-adjacent to each other;
  • there cannot be more than 7 teleporters in the room.

I think this works for non-rectangular rooms as well, with the modification that such rooms have more than four corners.

@davidbau

davidbau commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

interesting. yes, i think that as long as traps don't bisect a room in the wrong way it wouldn't cause this problem.

But also I think: clustering the teleportation hubs in the center of the room "looks more intentional," which might be a nice effect. I imagine it might be the layout a dungeon architect might pick it if really designing a hub.

@copperwater

Copy link
Copy Markdown
Contributor

A more general fix would be to avoid placing traps in themed rooms next to doors, as is the case in ordinary rooms. The reason this isn't done already is that whereas ordinary rooms wait to fill their contents until after doors and corridors generate in the level, themed rooms generate them immediately.

Maybe some type of post-door-creation fixup where rooms are scanned for traps (and blocking terrain, like trees) orthogonally adjacent to a door, and thence shuffled off to some other available space in the room?

Or make it so that the room filling functions get defined, but not actually executed, until after doors and corridors appear?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

teleportation hub room can yield a map that traps the hero by making stairs inaccessible

3 participants