Varied-width tunnels, and stop carving slits in the boss arenas

Every corridor was one tile wide, which in a bullet hell is a shooting
gallery: there is no side to step to, so anything fired down it lands.
Each leg of each L now rolls its own width between 2 and 4, so a tunnel
can open up or pinch at its bend rather than every connection being the
same pipe. Carving stops one tile short of the map's outer ring, which
keeps the world sealed however close to the edge a wide tunnel runs.

Found while doing it: 45% of generated arenas had their own walls carved
open. The last corridor aimed at the door tile, which sits ON the
arena's west wall, and an L that bent the other way ran its second leg
straight down that column -- 181 of 398 arenas, measured. It now aims at
the tile outside the door and always arrives along the door's own row,
and the arena is excluded from every carve, so a wide tunnel stops at
the wall instead of eating into it.

Three tests: no corridor tile sits in a passage one tile wide, every
width in the range turns up and none falls below two, and every arena
keeps every wall tile it was drawn with. The overshoot at a bend is
cosmetic -- the legs always overlap on the inner side, so removing it
bevels the outer corner and narrows nothing -- and the comment now says
so rather than claiming otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-05 09:51:19 +02:00
1 parent a6084c1a8d
commit 83c3b920fb
2 files changed
+157 -19

No files matched your search

+82
View File
@@ -83,3 +83,85 @@ func test_rooms_do_not_overlap() -> void:
for j in range(i + 1, rooms.size()):
assert_false((rooms[i] as Rect2i).intersects(rooms[j]),
"rooms %d and %d overlap" % [i, j])
# --- Tunnels ----------------------------------------------------------------
func _inside_any(rooms: Array, x: int, y: int) -> bool:
for r: Rect2i in rooms:
if r.has_point(Vector2i(x, y)):
return true
return false
## Whether (x, y) is a corner of at least one 2x2 square of open floor. A
## passage one tile wide has no such square anywhere along it.
func _in_open_square(g: MapGrid, x: int, y: int) -> bool:
for dy in [-1, 0]:
for dx in [-1, 0]:
var ok := true
for oy in 2:
for ox in 2:
if g.at(x + dx + ox, y + dy + oy) != MapGrid.Kind.FLOOR:
ok = false
if ok:
return true
return false
func test_no_tunnel_is_a_single_file_squeeze() -> void:
# A one-tile corridor in a bullet hell is a shooting gallery: there is no
# side to step to. Every corridor tile has to sit in open ground at least
# two wide in some direction. Rooms and the authored arena are left out --
# the arena's door is drawn one tile wide on purpose.
for s in range(1, 40):
var m := MapGen.generate(s * 7919, 1 + (s % 5))
var g: MapGrid = m["grid"]
var rooms: Array = m["rooms"]
var arena: Rect2i = m["boss_room"]
var squeezes := 0
for y in g.height:
for x in g.width:
if g.at(x, y) != MapGrid.Kind.FLOOR:
continue
if _inside_any(rooms, x, y) or arena.has_point(Vector2i(x, y)):
continue
if not _in_open_square(g, x, y):
squeezes += 1
assert_eq(squeezes, 0,
"seed %d: %d corridor tile(s) in a passage one tile wide" % [s, squeezes])
func test_tunnel_widths_vary_and_never_go_below_two() -> void:
var seen := {}
for s in range(1, 40):
var widths: PackedInt32Array = MapGen.generate(s * 7919, 1 + (s % 5))["corridor_widths"]
assert_false(widths.is_empty(), "seed %d carved no tunnels at all" % s)
for w in widths:
assert_between(w, MapGen.CORRIDOR_MIN_WIDTH, MapGen.CORRIDOR_MAX_WIDTH)
seen[w] = true
assert_eq(seen.size(), MapGen.CORRIDOR_MAX_WIDTH - MapGen.CORRIDOR_MIN_WIDTH + 1,
"every width in the range turns up somewhere; got %s" % [seen.keys()])
func test_the_arena_keeps_every_wall_it_was_drawn_with() -> void:
# The corridor to the door used to aim at the door tile itself, which sits
# ON the arena's west wall. An L that bent the other way ran its second leg
# down that wall column, and 45% of generated arenas had a slit carved in
# an authored room. A wide tunnel makes the same mistake wider.
for arena in [&"warden_hall", &"choir_vault"]:
var stamp := Rooms.warden_hall() if arena == &"warden_hall" else Rooms.choir_vault()
for s in range(1, 60):
var m := MapGen.generate(s * 7919, 1 + (s % 5), arena)
var g: MapGrid = m["grid"]
var room: Rect2i = m["boss_room"]
var carved := 0
for y in stamp.size():
for x in stamp[y].length():
if stamp[y][x] != "#":
continue
if g.at(room.position.x + x, room.position.y + y) != MapGrid.Kind.WALL:
carved += 1
assert_eq(carved, 0,
"seed %d %s: %d of the arena's own wall tiles were carved open"
% [s * 7919, arena, carved])