- Regions are now dense labyrinths (recursive backtracker on a coarse grid, 1-3 tile corridors, braided loops by complexity); tubes run in the rock between regions, wall pipes give shortcuts inside a region. - One-way entrances suck the slime in (player.pull_into_tube); blow zone is now 1 tile; blown motes are white. TubeBlower -> TubeAirCurrents. - Validator: generous "might get to" areas vs strict SlimeMoves model (surface slides, corners, wraps, 1-tile gaps, ceiling falls, tubes, forced suction/blow tiles as all-outcomes states). - maze_check: new hand-made blow-zone and suction traps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.2 KiB
GDScript
35 lines
1.2 KiB
GDScript
class_name MazeBuilder
|
|
extends RefCounted
|
|
|
|
# Makes a maze in a TileMapLayer: graph, then tiles, then the soft-lock check.
|
|
# A maze that fails (a tube couldn't be routed, or the check found a problem)
|
|
# is thrown away and the next seed tried. MazeLevel and tests/maze_check.gd
|
|
# use this.
|
|
|
|
const MAX_ATTEMPTS = 30
|
|
|
|
var isValid := false
|
|
var attempts := 0 # How many mazes it took (1 = the first one passed).
|
|
var usedSeed := 0
|
|
var carver: MazeCarver
|
|
var validator: MazeValidator
|
|
var problems: Array[String] = [] # Why each thrown-away maze failed.
|
|
|
|
|
|
func _init(layer: TileMapLayer, screens: Vector2i, complexity: int, firstSeed: int) -> void:
|
|
var level := MazeSettings.get_level(complexity)
|
|
for attempt in MAX_ATTEMPTS:
|
|
attempts = attempt + 1
|
|
usedSeed = firstSeed + attempt
|
|
var random := RandomNumberGenerator.new()
|
|
random.seed = usedSeed
|
|
var graph := MazeGraph.new(screens, level, random)
|
|
carver = MazeCarver.new(graph, screens, layer, random, level)
|
|
if not carver.isComplete:
|
|
problems.append("seed %d: a tube couldn't be routed" % usedSeed)
|
|
continue
|
|
validator = MazeValidator.new(layer, carver.bounds, carver.startCell, carver.endCell)
|
|
if validator.isValid:
|
|
isValid = true
|
|
return
|
|
problems.append("seed %d: %s" % [usedSeed, validator.problem])
|