- Air blows out of one-way exits: orange motes stream out (TubeAirflow, renamed from TubeVacuum, now draws intake and blow) and TubeBlower pushes the slime within 2 tiles of the mouth via player.blow_away(): knocked off walls/ceilings, lifted off the floor. - Generator: at most one one-way tube comes out in each chamber; no other mouth, Start or End inside a blow zone. - Validator (from tiles, via OneWayTube.find_exits/blow_zone): checks the same rules, so each chamber's crawlable boundary stays connected. - maze_check: also checks Start in a blow zone is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 KiB
Maze mode
A "Maze" button on the main menu asks for a size and a complexity, then generates a level of rock chambers joined by tubes, with a Start and an End.
Goals (checkable)
- Main menu has a Maze button. It opens a setup panel (same look as Options) with Width (1-4 screens), Height (1-3 screens) and Complexity (1-5), plus Generate and Back.
- Generate builds a maze level from those inputs and a random seed. The same inputs and seed always give the same maze.
- The maze spans
Width x Heightscreens (one screen = 20 x 15 tiles, the RoomCamera's room). Chambers sit inside screens; tubes run through the rock inside a screen and across screen borders. - It uses the existing tube kinds (auto, manual, goo) and a new one-way kind.
- One-way tubes: orange tiles; only their entrance mouth lets the slime in;
orange motes drift into the entrance like a vacuum. Built by extending the
existing tube code (the auto tube's
PixelStream), not by copying it. 5b. Air blows out of a one-way tube's exit: orange motes stream out of it, and within 2 tiles straight out of the mouth (the "blow zone") the slime is knocked off a wall or ceiling, or lifted off the floor (240 px/s away from the mouth; sideways blowers also lift at 120 px/s). It can never be pinned. - Start and End are clearly visible (a green START pad, a gold END pad). Touching End shows a win panel with New maze and Main menu.
- No soft-locks. For every chamber the slime can reach from Start, End is still reachable. Checked on the finished tiles by a validator that does not trust the generator; a failed maze is thrown away and the next seed tried.
- A headless check generates many mazes (all sizes, complexities, many seeds) and runs the validator on each. Target: 100 % pass on the first try.
What the inputs control:
| Complexity | Chambers per screen | One-way tubes on the Start-End route | Extra tubes (per screen) | Steered (manual/goo) share | Tube winding |
|---|---|---|---|---|---|
| 1 | 2 x 1 | 0 | 0 | 0 % | low |
| 2 | 2 x 2 | 1 | 0.5 | 20 % | low |
| 3 | 2 x 2 | 2 | 1 | 30 % | medium |
| 4 | 3 x 2 | 3 | 1.5 | 35 % | high |
| 5 | 3 x 2 | 4 | 2 | 40 % | high |
Extra tubes are about half one-way (traps/shortcuts), half two-way (loops).
Non-goals
- No change to player movement, existing levels or other menus (besides the
one button). The player only gains what the new tube kind needs: one-way
tubes only let it in at their entrance, and
blow_away()for the air out of their exits. - No tube crossings or branching tube networks in mazes.
- No ledges, hazards, items or enemies inside chambers: chambers are plain rectangles (this is what keeps the movement model below exact).
- No saving of mazes; the seed is not shown in the UI.
How the player moves (the model the check uses)
From Characters/player.gd: the slime crawls on floors, walls and ceilings,
wraps round outside corners and takes inside corners. So inside one closed
rectangle of air it can reach every spot on the rectangle's boundary, and so
every tube mouth in it. Chambers are therefore nodes of a graph, and the only
ways between them are tubes:
- Auto tube (green): either end in, traced to the other end
(
PixelStream.trace_tube, the same function the player uses). Edge both ways. - One-way tube (orange): an auto tube that only accepts the slime at the
mouth whose tile is marked as the entrance (
OneWayTube.can_enter, also used by the player). Edge from the entrance chamber to the exit chamber only. - Manual / goo tubes (grey / pink): steered; the slime can come out of any mouth with room or back out. Edges between all their mouths' chambers.
- A mouth only counts as an exit if the tile in front of it is air (room for the slime to reform).
Blow zones
The slime can't stay in a blow zone, so the zone's tiles are taken out of the chamber. A zone is a strip straight out from one wall, shorter than the chamber is deep that way. It cuts the chamber's boundary loop (the tile sides the slime crawls round) in one place only, so every other part of the loop is still reachable the other way round. Two zones could cut the loop twice and split the chamber, so the model holds only if:
- each chamber has at most one blow zone (the generator lets at most one one-way tube come out in each chamber);
- a zone is shorter than its chamber in its direction (chambers are at least 3 tiles; zones at most 2);
- no other tube mouth opens into a zone, and Start and End are not in one.
Not pinned: outside the zone there is no push, the push always points out of the zone, and the slime can steer in the air. A floor blower lifts it up to the ceiling or out of the zone; it can then crawl or fall away.
The soft-lock check (MazeValidator)
Works only from the TileMapLayer:
- Flood-fill the air cells inside the maze into chambers. Fail if air leaks
out of the maze bounds or a chamber is not a full rectangle (the movement
model above would not hold).
1b. Check the blow zone rules above (rebuilt from the tiles with
OneWayTube.find_exitsandblow_zone, the same functions the game uses). - Find every tube mouth (a tube tile side that is open onto air).
- Build a directed chamber graph from the tube rules above.
- Forward search from the Start chamber gives
reachable. Backward search (reversed edges) from the End chamber givescanFinish. - Pass if End is in
reachableand every chamber inreachableis also incanFinish. That is the no-soft-lock rule; "Start reaches End" alone is not enough, because a one-way tube could drop the slime where End is out of reach.
Approaches considered
- Chamber graph first, then carve tiles (chosen). Lay out a grid of
rectangular chambers, build a spanning tree over neighbouring chambers
(a classic maze), pick Start and End, root the tree at End, make some tree
edges on the Start-End route one-way towards End, and add extra tubes. Then
carve: rock everywhere, air chambers, each tube routed through the rock with
AStarGrid2Dand random weights so tubes wind. Safe by construction: with the tree rooted at End and every tree edge usable towards End, every chamber can reach End, so any extra tube in any direction is safe. The validator then checks the real tiles anyway. - Tile-level random level + search. Random caves and random tubes, then
a search over the player's moves at tile level, keep if it passes. Simple to
write but most tries fail, with no control over difficulty; the per-tile
movement search is also a big, fragile copy of
player.gd. - Template rooms stitched together. Hand-made screens with tube stubs at the edges, joined like jigsaw pieces. Looks good, but needs many hand-made rooms, gives little variety per size, and one-way placement still needs the same graph reasoning as approach 1.
- Graph with a solver-guided one-way search. Start from a strongly connected graph and keep adding one-way tubes while a solver says it is still safe. Works, but is slower and less predictable than approach 1, which gets the same safety for free from the rooted tree.
Approach 1 meets every goal: inputs map directly to grid size and edge counts, chambers stay plain rectangles (so the movement model is exact), tubes cross screens naturally, and safety does not depend on luck.
Files
UI/maze_setup_menu.*- the size/complexity panel.Levels/Maze/maze_settings.gd- the chosen inputs (static, read by the level).Levels/Maze/maze_graph.gd- chambers, spanning tree, one-way and extra tubes.Levels/Maze/maze_carver.gd- turns the graph into tiles, routes tubes.Levels/Maze/maze_tiles.gd- finds the right tile for a tube shape and kind.Levels/Maze/maze_validator.gd- the soft-lock check.Levels/Maze/maze_builder.gd- graph, carve, check; next seed on failure.Levels/Maze/maze_level.*- the playable scene: generate, validate, place.Levels/Maze/maze_marker.gd- the Start and End pads.Levels/Maze/maze_win_menu.*- the win panel.Effects/one_way_tube.gd- one-way tube rules (entrance check).Effects/pixel_stream.gd-trace_tube(), moved here fromplayer.gdso the player and the validator share it.Assets/level_tiles.tres- orange alternatives 3-5 on the six two-sided tube tiles (3 = body/exit, 4 and 5 = entrance on each side), and thetube_one_way/tube_one_way_entrycustom data layers.Effects/tube_airflow.gd- orange motes drifting into entrances and blown out of exits.Effects/tube_blower.gd- pushes the slime in blow zones (calls the player'sblow_away()).tests/maze_check.gd- the headless batch check.
Run the check:
godot --headless --audio-driver Dummy --script res://tests/maze_check.gd
The check also checks the validator rejects Start inside a blow zone, and builds one known soft-lock (a chamber whose tubes are all turned into one-way tubes leading in, while Start still reaches End another way) and makes sure the validator rejects it.